2
2
cmake_minimum_required (VERSION 3.13.4 )
3
3
project (Runtimes C CXX ASM )
4
4
5
- set (LLVM_ALL_RUNTIMES "compiler-rt;libc;libcxx;libcxxabi;libunwind;openmp" )
5
+ # Add path for custom and the LLVM build's modules to the CMake module path.
6
+ set (LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR} /../cmake" )
7
+ list (INSERT CMAKE_MODULE_PATH 0
8
+ "${CMAKE_CURRENT_SOURCE_DIR} /cmake"
9
+ "${CMAKE_CURRENT_SOURCE_DIR} /cmake/modules"
10
+ "${LLVM_COMMON_CMAKE_UTILS} "
11
+ "${LLVM_COMMON_CMAKE_UTILS} /Modules"
12
+ "${CMAKE_CURRENT_SOURCE_DIR} /../llvm/cmake"
13
+ "${CMAKE_CURRENT_SOURCE_DIR} /../llvm/cmake/modules"
14
+ )
15
+
16
+ # We order libraries to mirror roughly how they are layered, except that compiler-rt can depend
17
+ # on libc++, so we put it after.
18
+ set (LLVM_ALL_RUNTIMES "libc;libunwind;libcxxabi;libcxx;compiler-rt;openmp" )
6
19
set (LLVM_ENABLE_RUNTIMES "" CACHE STRING
7
20
"Semicolon-separated list of runtimes to build (${LLVM_ALL_RUNTIMES} ), or \" all\" ." )
8
21
if (LLVM_ENABLE_RUNTIMES STREQUAL "all" )
9
22
set (LLVM_ENABLE_RUNTIMES ${LLVM_ALL_RUNTIMES} )
10
23
endif ()
11
-
12
- # Some of the runtimes will conditionally use the compiler-rt sanitizers.
13
- # To make this work smoothly, we ensure that compiler-rt is added first in
14
- # the list of sub-projects. This allows other sub-projects to have checks
15
- # like `if(TARGET asan)` to enable building with asan.
16
- if (compiler-rt IN_LIST LLVM_ENABLE_RUNTIMES )
17
- list (REMOVE_ITEM LLVM_ENABLE_RUNTIMES compiler-rt )
18
- if (NOT DEFINED LLVM_BUILD_COMPILER_RT OR LLVM_BUILD_COMPILER_RT )
19
- list (PREPEND LLVM_ENABLE_RUNTIMES compiler-rt )
20
- endif ()
21
- endif ()
22
-
23
- # If both libc++ and libc++abi are being built, always configure libc++abi before libc++.
24
- # This allows libc++ to depend on targets set up by libc++abi when it needs to.
25
- if (libcxx IN_LIST LLVM_ENABLE_RUNTIMES AND libcxxabi IN_LIST LLVM_ENABLE_RUNTIMES )
26
- list (FIND LLVM_ENABLE_RUNTIMES libcxx _libcxx_index )
27
- list (FIND LLVM_ENABLE_RUNTIMES libcxxabi _libcxxabi_index )
28
- if (_libcxx_index LESS _libcxxabi_index )
29
- list (TRANSFORM LLVM_ENABLE_RUNTIMES REPLACE "^libcxx$" "libcxxabi" AT ${_libcxx_index} )
30
- list (TRANSFORM LLVM_ENABLE_RUNTIMES REPLACE "^libcxxabi$" "libcxx" AT ${_libcxxabi_index} )
31
- endif ()
32
- endif ()
24
+ include (SortSubset )
25
+ sort_subset ("${LLVM_ALL_RUNTIMES} " "${LLVM_ENABLE_RUNTIMES} " LLVM_ENABLE_RUNTIMES )
33
26
34
27
foreach (proj ${LLVM_ENABLE_RUNTIMES} )
35
28
set (proj_dir "${CMAKE_CURRENT_SOURCE_DIR} /../${proj} " )
@@ -50,18 +43,6 @@ endfunction()
50
43
find_package (LLVM PATHS "${LLVM_BINARY_DIR} " NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH )
51
44
find_package (Clang PATHS "${LLVM_BINARY_DIR} " NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH )
52
45
53
- set (LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR} /../cmake" )
54
-
55
- # Add path for custom and the LLVM build's modules to the CMake module path.
56
- list (INSERT CMAKE_MODULE_PATH 0
57
- "${CMAKE_CURRENT_SOURCE_DIR} /cmake"
58
- "${CMAKE_CURRENT_SOURCE_DIR} /cmake/modules"
59
- "${LLVM_COMMON_CMAKE_UTILS} "
60
- "${LLVM_COMMON_CMAKE_UTILS} /Modules"
61
- "${CMAKE_CURRENT_SOURCE_DIR} /../llvm/cmake"
62
- "${CMAKE_CURRENT_SOURCE_DIR} /../llvm/cmake/modules"
63
- )
64
-
65
46
set (LLVM_THIRD_PARTY_DIR "${CMAKE_CURRENT_SOURCE_DIR} /../third-party" )
66
47
67
48
# If building standalone by pointing CMake at this runtimes directory,
0 commit comments