llvm.org GIT mirror llvm / 78cca47
Revert r241621, "[CMake] Cleanup tools/CMakeLists.txt to take advantage of the auto-registration that was already partially working." It broke the build that relies on LLVM_EXTERNAL_CLANG_*. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241663 91177308-0d34-0410-b5e6-96231b3b80d8 NAKAMURA Takumi 4 years ago
2 changed file(s) with 89 addition(s) and 53 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 set(LLVM_TOOL_${nameUPPER}_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/${add_llvm_external_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}"
697692 CACHE PATH "Path to ${name} source directory")
698 if (NOT ${LLVM_TOOL_${nameUPPER}_SOURCE_DIR} STREQUAL ""
699 AND EXISTS ${LLVM_TOOL_${nameUPPER}_SOURCE_DIR}/CMakeLists.txt)
700 option(LLVM_TOOL_${nameUPPER}_BUILD
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
701696 "Whether to build ${name} as part of LLVM" ON)
702 if (LLVM_TOOL_${nameUPPER}_BUILD)
703 add_subdirectory(${LLVM_TOOL_${nameUPPER}_SOURCE_DIR} ${add_llvm_external_dir})
704 set(LLVM_TOOL_${nameUPPER}_BUILD Off)
697 if (LLVM_EXTERNAL_${nameUPPER}_BUILD)
698 add_subdirectory(${LLVM_EXTERNAL_${nameUPPER}_SOURCE_DIR} ${add_llvm_external_dir})
705699 endif()
706700 endif()
707701 endmacro(add_llvm_external_project)
708702
709703 macro(add_llvm_tool_subdirectory name)
710 set(LLVM_TOOL_${nameUPPER}_BUILD Off)
704 list(APPEND LLVM_IMPLICIT_PROJECT_IGNORE "${CMAKE_CURRENT_SOURCE_DIR}/${name}")
711705 add_subdirectory(${name})
712706 endmacro(add_llvm_tool_subdirectory)
713707
714 function(create_llvm_tool_options)
715 file(GLOB sub-dirs "${CMAKE_CURRENT_SOURCE_DIR}/*")
716 foreach(dir ${sub-dirs})
717 if(IS_DIRECTORY "${dir}" AND EXISTS "${dir}/CMakeLists.txt")
718 canonicalize_tool_name(${dir} name)
719 option(LLVM_TOOL_${name}_BUILD
720 "Whether to build ${name} as part of LLVM" On)
721 endif()
722 endforeach()
723 endfunction(create_llvm_tool_options)
724
725 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)
726713 set(list_of_implicit_subdirs "")
727714 file(GLOB sub-dirs "${CMAKE_CURRENT_SOURCE_DIR}/*")
728715 foreach(dir ${sub-dirs})
729 if(IS_DIRECTORY "${dir}" AND EXISTS "${dir}/CMakeLists.txt")
730 canonicalize_tool_name(${dir} name)
731 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")
732720 get_filename_component(fn "${dir}" NAME)
733721 list(APPEND list_of_implicit_subdirs "${fn}")
734722 endif()
738726 foreach(external_proj ${list_of_implicit_subdirs})
739727 add_llvm_external_project("${external_proj}")
740728 endforeach()
741 endfunction(add_llvm_implicit_projects)
729 endfunction(add_llvm_implicit_external_projects)
742730
743731 # Generic support for adding a unittest.
744732 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)