1 # This file will recurse into all subdirectories that contain CMakeLists.txt
2 # Setting variables that match the pattern LLVM_TOOL_{NAME}_BUILD to Off will
3 # prevent traversing into a directory.
5 # The only tools that need to be explicitly added are ones that have explicit
6 # ordering requirements.
8 # Iterates all the subdirectories to create CMake options to enable/disable
9 # traversing each directory.
10 create_llvm_tool_options()
12 if(NOT LLVM_BUILD_LLVM_DYLIB AND NOT LLVM_BUILD_LLVM_C_DYLIB)
13 set(LLVM_TOOL_LLVM_SHLIB_BUILD Off)
16 if(NOT LLVM_USE_INTEL_JITEVENTS )
17 set(LLVM_TOOL_LLVM_JITLISTENER_BUILD Off)
20 if(CYGWIN OR NOT LLVM_ENABLE_PIC)
21 set(LLVM_TOOL_LTO_BUILD Off)
24 if (LLVM_TOOL_LLVM_DRIVER_BUILD)
25 add_llvm_tool(llvm-driver)
28 # Add LTO, llvm-ar, llvm-config, and llvm-profdata before clang, ExternalProject
29 # requires targets specified in DEPENDS to exist before the call to
30 # ExternalProject_Add.
31 add_llvm_tool_subdirectory(lto)
32 add_llvm_tool_subdirectory(gold)
33 add_llvm_tool_subdirectory(llvm-ar)
34 add_llvm_tool_subdirectory(llvm-config)
35 add_llvm_tool_subdirectory(llvm-lto)
36 add_llvm_tool_subdirectory(llvm-profdata)
38 # Projects supported via LLVM_EXTERNAL_*_SOURCE_DIR need to be explicitly
40 add_llvm_external_project(lld)
41 add_llvm_external_project(mlir)
42 # ClangIR and Flang depend on mlir, lldb and Flang depend on clang, sort them
43 # accordingly so place them afterwards
44 add_llvm_external_project(clang)
45 add_llvm_external_project(flang)
46 add_llvm_external_project(lldb)
47 add_llvm_external_project(bolt)
49 # Automatically add remaining sub-directories containing a 'CMakeLists.txt'
50 # file as external projects.
51 add_llvm_implicit_projects()
53 add_llvm_external_project(polly)
55 # libclc depends on clang
56 add_llvm_external_project(libclc)
58 # Add subprojects specified using LLVM_EXTERNAL_PROJECTS
59 foreach(p ${LLVM_EXTERNAL_PROJECTS})
60 add_llvm_external_project(${p})
63 set(LLVM_COMMON_DEPENDS ${LLVM_COMMON_DEPENDS} PARENT_SCOPE)
65 if (LLVM_TOOL_LLVM_DRIVER_BUILD)
66 # This is explicitly added at the end _after_ all tool projects so that it can
67 # scrape up tools from other projects into itself.
68 add_subdirectory(llvm-driver)
69 # This must be here otherwise CMake complains in add_llvm_tool_symlink that
70 # it can't add_custom_command that happens after llvm-driver is built because
71 # llvm-driver was not created in that directory.
72 generate_driver_tool_targets()