llvm.org GIT mirror llvm / 7d41350
Revert "[CMake] Cleanup tools/CMakeLists.txt to take advantage of the auto-registration that was already partially working." Reverting r242059 because it broke some bots. I'm attempting to reproduce the failures now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242060 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Bieneman 4 years ago
2 changed file(s) with 91 addition(s) and 86 deletion(s). Raw diff Collapse all Expand all
675675 set( CURRENT_LLVM_TARGET LLVM${target_name} )
676676 endmacro(add_llvm_target)
677677
678 function(canonicalize_tool_name name output)
679 string(REPLACE "${CMAKE_CURRENT_SOURCE_DIR}/" "" nameStrip ${name})
680 string(REPLACE "-" "_" nameUNDERSCORE ${nameStrip})
681 string(TOUPPER ${nameUNDERSCORE} nameUPPER)
682 set(${output} "${nameUPPER}" PARENT_SCOPE)
683 endfunction(canonicalize_tool_name)
684
685678 # Add external project that may want to be built as part of llvm such as Clang,
686679 # lld, and Polly. This adds two options. One for the source directory of the
687680 # project, which defaults to ${CMAKE_CURRENT_SOURCE_DIR}/${name}. Another to
692685 if("${add_llvm_external_dir}" STREQUAL "")
693686 set(add_llvm_external_dir ${name})
694687 endif()
695 canonicalize_tool_name(${name} nameUPPER)
696 if (LLVM_TOOL_${nameUPPER}_BUILD)
697 if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir}/CMakeLists.txt)
698 add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir} ${add_llvm_external_dir})
699 set(LLVM_TOOL_${nameUPPER}_BUILD Off)
700 elseif(LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR)
701 set(LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR
702 "${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR}"
703 CACHE PATH "Path to ${name} source directory")
704 mark_as_advanced(LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR)
688 list(APPEND LLVM_IMPLICIT_PROJECT_IGNORE "${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir}")
689 string(REPLACE "-" "_" nameUNDERSCORE ${name})
690 string(TOUPPER ${nameUNDERSCORE} nameUPPER)
691 set(LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_dir}"
692 CACHE PATH "Path to ${name} source directory")
693 if (NOT ${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR} STREQUAL ""
694 AND EXISTS ${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR}/CMakeLists.txt)
695 option(LLVM_EXTERNAL_${nameUPPER}_BUILD
696 "Whether to build ${name} as part of LLVM" ON)
697 if (LLVM_EXTERNAL_${nameUPPER}_BUILD)
705698 add_subdirectory(${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR} ${add_llvm_external_dir})
706 set(LLVM_TOOL_${nameUPPER}_BUILD Off)
707699 endif()
708700 endif()
709701 endmacro(add_llvm_external_project)
710702
711703 macro(add_llvm_tool_subdirectory name)
712 add_llvm_external_project(${name})
704 list(APPEND LLVM_IMPLICIT_PROJECT_IGNORE "${CMAKE_CURRENT_SOURCE_DIR}/${name}")
705 add_subdirectory(${name})
713706 endmacro(add_llvm_tool_subdirectory)
714707
715 function(get_project_name_from_src_var var output)
716 string(REGEX MATCH "LLVM_EXTERNAL_(.*)_SOURCE_DIR"
717 MACHED_TOOL "${var}")
718 if(MACHED_TOOL)
719 set(${output} ${CMAKE_MATCH_1} PARENT_SCOPE)
720 else()
721 set(${output} PARENT_SCOPE)
722 endif()
723 endfunction()
724
725 function(create_llvm_tool_options)
726 file(GLOB sub-dirs "${CMAKE_CURRENT_SOURCE_DIR}/*")
727 foreach(dir ${sub-dirs})
728 if(IS_DIRECTORY "${dir}" AND EXISTS "${dir}/CMakeLists.txt")
729 canonicalize_tool_name(${dir} name)
730 option(LLVM_TOOL_${name}_BUILD
731 "Whether to build ${name} as part of LLVM" On)
732 mark_as_advanced(LLVM_TOOL_${name}_BUILD)
733 endif()
734 endforeach()
735 get_cmake_property(variableNames VARIABLES)
736 foreach (variableName ${variableNames})
737 get_project_name_from_src_var(${variableName} projectName)
738 if(projectName)
739 option(LLVM_TOOL_${projectName}_BUILD
740 "Whether to build ${name} as part of LLVM" On)
741 mark_as_advanced(LLVM_TOOL_${name}_BUILD)
742 endif()
743 endforeach()
744 endfunction(create_llvm_tool_options)
745
746 function(add_llvm_implicit_projects)
708 macro(ignore_llvm_tool_subdirectory name)
709 list(APPEND LLVM_IMPLICIT_PROJECT_IGNORE "${CMAKE_CURRENT_SOURCE_DIR}/${name}")
710 endmacro(ignore_llvm_tool_subdirectory)
711
712 function(add_llvm_implicit_external_projects)
747713 set(list_of_implicit_subdirs "")
748714 file(GLOB sub-dirs "${CMAKE_CURRENT_SOURCE_DIR}/*")
749715 foreach(dir ${sub-dirs})
750 if(IS_DIRECTORY "${dir}" AND EXISTS "${dir}/CMakeLists.txt")
751 canonicalize_tool_name(${dir} name)
752 if (LLVM_TOOL_${name}_BUILD)
716 if(IS_DIRECTORY "${dir}")
717 list(FIND LLVM_IMPLICIT_PROJECT_IGNORE "${dir}" tool_subdir_ignore)
718 if( tool_subdir_ignore EQUAL -1
719 AND EXISTS "${dir}/CMakeLists.txt")
753720 get_filename_component(fn "${dir}" NAME)
754721 list(APPEND list_of_implicit_subdirs "${fn}")
755722 endif()
756723 endif()
757724 endforeach()
758725
759 get_cmake_property(variableNames VARIABLES)
760 foreach (variableName ${variableNames})
761 get_project_name_from_src_var(${variableName} projectName)
762 if(projectName)
763 string(TOLOWER ${projectName} projectName)
764 list(APPEND list_of_implicit_subdirs ${projectName})
765 endif()
766 endforeach()
767
768 list(REMOVE_DUPLICATES list_of_implicit_subdirs)
769726 foreach(external_proj ${list_of_implicit_subdirs})
770727 add_llvm_external_project("${external_proj}")
771728 endforeach()
772 endfunction(add_llvm_implicit_projects)
729 endfunction(add_llvm_implicit_external_projects)
773730
774731 # Generic support for adding a unittest.
775732 function(add_unittest test_suite test_name)
None # This file will recurse into all subdirectories that contain CMakeLists.txt
1 # Setting variables that match the pattern LLVM_TOOL_{NAME}_BUILD to Off will
2 # prevent traversing into a directory.
3 #
4 # The only tools that need to be explicitly added are ones that have explicit
5 # ordering requirements.
6
7 # Iterates all the subdirectories to create CMake options to enable/disable
8 # traversing each directory.
9 create_llvm_tool_options()
0 add_llvm_tool_subdirectory(llvm-config)
101
112 # Build polly before the tools: the tools link against polly when
123 # LINK_POLLY_INTO_TOOLS is set.
134 if(WITH_POLLY)
145 add_llvm_external_project(polly)
6 else(WITH_POLLY)
7 list(APPEND LLVM_IMPLICIT_PROJECT_IGNORE "${LLVM_MAIN_SRC_DIR}/tools/polly")
8 endif(WITH_POLLY)
9
10 if( LLVM_BUILD_LLVM_DYLIB )
11 add_llvm_tool_subdirectory(llvm-shlib)
1512 else()
16 set(LLVM_TOOL_POLLY_BUILD Off)
13 ignore_llvm_tool_subdirectory(llvm-shlib)
1714 endif()
1815
19 if(NOT LLVM_BUILD_LLVM_DYLIB )
20 set(LLVM_TOOL_LLVM_SHLIB_BUILD Off)
16 add_llvm_tool_subdirectory(opt)
17 add_llvm_tool_subdirectory(llvm-as)
18 add_llvm_tool_subdirectory(llvm-dis)
19 add_llvm_tool_subdirectory(llvm-mc)
20
21 add_llvm_tool_subdirectory(llc)
22 add_llvm_tool_subdirectory(llvm-ar)
23 add_llvm_tool_subdirectory(llvm-nm)
24 add_llvm_tool_subdirectory(llvm-size)
25
26 add_llvm_tool_subdirectory(llvm-cov)
27 add_llvm_tool_subdirectory(llvm-profdata)
28 add_llvm_tool_subdirectory(llvm-link)
29 add_llvm_tool_subdirectory(lli)
30
31 add_llvm_tool_subdirectory(llvm-extract)
32 add_llvm_tool_subdirectory(llvm-diff)
33 add_llvm_tool_subdirectory(macho-dump)
34 add_llvm_tool_subdirectory(llvm-objdump)
35 add_llvm_tool_subdirectory(llvm-readobj)
36 add_llvm_tool_subdirectory(llvm-rtdyld)
37 add_llvm_tool_subdirectory(llvm-dwarfdump)
38 add_llvm_tool_subdirectory(dsymutil)
39 add_llvm_tool_subdirectory(llvm-cxxdump)
40 if( LLVM_USE_INTEL_JITEVENTS )
41 add_llvm_tool_subdirectory(llvm-jitlistener)
42 else()
43 ignore_llvm_tool_subdirectory(llvm-jitlistener)
44 endif( LLVM_USE_INTEL_JITEVENTS )
45
46 add_llvm_tool_subdirectory(bugpoint)
47 add_llvm_tool_subdirectory(bugpoint-passes)
48 add_llvm_tool_subdirectory(llvm-bcanalyzer)
49 add_llvm_tool_subdirectory(llvm-stress)
50 add_llvm_tool_subdirectory(llvm-mcmarkup)
51
52 add_llvm_tool_subdirectory(verify-uselistorder)
53
54 add_llvm_tool_subdirectory(llvm-symbolizer)
55
56 add_llvm_tool_subdirectory(llvm-c-test)
57
58 add_llvm_tool_subdirectory(obj2yaml)
59 add_llvm_tool_subdirectory(yaml2obj)
60
61 add_llvm_tool_subdirectory(llvm-go)
62
63 add_llvm_tool_subdirectory(llvm-pdbdump)
64
65 if(NOT CYGWIN AND LLVM_ENABLE_PIC)
66 add_llvm_tool_subdirectory(lto)
67 add_llvm_tool_subdirectory(llvm-lto)
68 else()
69 ignore_llvm_tool_subdirectory(lto)
70 ignore_llvm_tool_subdirectory(llvm-lto)
2171 endif()
2272
23 if(NOT LLVM_USE_INTEL_JITEVENTS )
24 set(LLVM_TOOL_LLVM_JITLISTENER_BUILD Off)
25 endif()
73 add_llvm_tool_subdirectory(gold)
2674
27 if(CYGWIN OR NOT LLVM_ENABLE_PIC)
28 set(LLVM_TOOL_LTO_BUILD Off)
29 set(LLVM_TOOL_LLVM_LTO_BUILD Off)
30 endif()
75 add_llvm_external_project(clang)
76 add_llvm_external_project(llgo)
77 add_llvm_external_project(lld)
78 add_llvm_external_project(lldb)
3179
3280 # Automatically add remaining sub-directories containing a 'CMakeLists.txt'
3381 # file as external projects.
34 add_llvm_implicit_projects()
82 add_llvm_implicit_external_projects()
3583
3684 set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} PARENT_SCOPE)