diff options
author | Zachary Turner <zturner@google.com> | 2017-09-12 23:32:34 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2017-09-12 23:32:34 +0000 |
commit | f98401fb5848559569eb1e94b8a785b16248efa6 (patch) | |
tree | 1771f5efaf444f04d708348fa69a27070978aa69 /CMakeLists.txt | |
parent | fd50a2ebe13b5ae0f7f77d9f5955eebf5f9f6811 (diff) | |
download | compiler-rt-f98401fb5848559569eb1e94b8a785b16248efa6.tar.gz |
Determine up front which projects are enabled.
Some projects need to add conditional dependencies on other projects.
compiler-rt is already doing this, and I attempted to add this to
debuginfo-tests when I ran into the ordering problem, that you can't
conditionally add a dependency unless that dependency's CMakeLists.txt
has already been run (which would allow you to say if (TARGET foo).
The solution to this seems to be to determine very early on the entire
set of projects which is enabled. This is complicated by the fact that
there are multiple ways to enable projects, and different tree layouts
(e.g. mono-repo, out of -tree, external, etc). This patch attempts to
centralize all of this into one place, and then updates compiler-rt to
demonstrate as a proof of concept how this can simplify code.
Differential Revision: https://reviews.llvm.org/D37637
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@313091 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 62118855b..cda9fb92e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,7 +225,7 @@ append_list_if(COMPILER_RT_DEBUG -DSANITIZER_DEBUG=1 SANITIZER_COMMON_CFLAGS) # always respect the optimization flags set by CMAKE_BUILD_TYPE instead. if (NOT MSVC) - # Build with optimization, unless we're in debug mode. + # Build with optimization, unless we're in debug mode. if(COMPILER_RT_DEBUG) list(APPEND SANITIZER_COMMON_CFLAGS -O0) else() @@ -315,28 +315,16 @@ endif() add_subdirectory(include) -set(COMPILER_RT_LIBCXX_PATH ${LLVM_MAIN_SRC_DIR}/projects/libcxx) -if(EXISTS ${COMPILER_RT_LIBCXX_PATH}/) - set(COMPILER_RT_HAS_LIBCXX_SOURCES TRUE) -else() - set(COMPILER_RT_LIBCXX_PATH ${LLVM_MAIN_SRC_DIR}/../libcxx) - if(EXISTS ${COMPILER_RT_LIBCXX_PATH}/) - set(COMPILER_RT_HAS_LIBCXX_SOURCES TRUE) - else() - set(COMPILER_RT_HAS_LIBCXX_SOURCES FALSE) - endif() +set(COMPILER_RT_HAS_LIBCXX_SOURCES ${LLVM_PROJECT_LIBCXX_ENABLED}) +if (LLVM_PROJECT_LIBCXX_ENABLED) + set(COMPILER_RT_LIBCXX_PATH ${LLVM_PROJECT_LIBCXX_SOURCE_DIR}) + message("compiler-rt libcxx enabled at ${COMPILER_RT_LIBCXX_PATH}") endif() -set(COMPILER_RT_LLD_PATH ${LLVM_MAIN_SRC_DIR}/tools/lld) -if(EXISTS ${COMPILER_RT_LLD_PATH}/ AND LLVM_TOOL_LLD_BUILD) - set(COMPILER_RT_HAS_LLD TRUE) -else() - set(COMPILER_RT_LLD_PATH ${LLVM_MAIN_SRC_DIR}/../lld) - if(EXISTS ${COMPILER_RT_LLD_PATH}/ AND LLVM_TOOL_LLD_BUILD) - set(COMPILER_RT_HAS_LLD TRUE) - else() - set(COMPILER_RT_HAS_LLD FALSE) - endif() +set(COMPILER_RT_HAS_LLD ${LLVM_PROJECT_LLD_ENABLED}) +if (LLVM_PROJECT_LLD_ENABLED) + set(COMPILER_RT_LLD_PATH ${LLVM_PROJECT_LLD_SOURCE_DIR}) + message("compiler-rt lld enabled at ${COMPILER_RT_LLD_PATH}") endif() pythonize_bool(COMPILER_RT_HAS_LLD) |