diff options
author | Petr Hosek <phosek@chromium.org> | 2017-12-12 01:20:52 +0000 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2017-12-12 01:20:52 +0000 |
commit | eff015538b70adcb9f3976ac8d2181513e28c1c1 (patch) | |
tree | 8ba95e68041087146a1ae57a941f47da8af4e706 | |
parent | 9b3f7c3d180b156605b9def01ce16465baee9c1c (diff) |
[CMake] Support runtimes and monorepo layouts when looking for libcxx
This also slightly refactors the code that's checking the directory
presence which allows eliminating one unnecessary variable.
Differential Revision: https://reviews.llvm.org/D40637
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@320446 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | CMakeLists.txt | 18 | ||||
-rw-r--r-- | cmake/Modules/AddCompilerRT.cmake | 2 | ||||
-rw-r--r-- | lib/msan/tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | lib/tsan/CMakeLists.txt | 2 | ||||
-rw-r--r-- | test/msan/CMakeLists.txt | 2 | ||||
-rw-r--r-- | test/tsan/CMakeLists.txt | 2 |
6 files changed, 13 insertions, 15 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e791089fe..4b953b212 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -344,17 +344,15 @@ 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) +foreach(path IN ITEMS ${LLVM_MAIN_SRC_DIR}/projects/libcxx + ${LLVM_MAIN_SRC_DIR}/runtimes/libcxx + ${LLVM_MAIN_SRC_DIR}/../libcxx + ${LLVM_EXTERNAL_LIBCXX_SOURCE_DIR}) + if(IS_DIRECTORY ${path}) + set(COMPILER_RT_LIBCXX_PATH ${path}) + break() endif() -endif() +endforeach() set(COMPILER_RT_LLD_PATH ${LLVM_MAIN_SRC_DIR}/tools/lld) if(EXISTS ${COMPILER_RT_LLD_PATH}/ AND LLVM_TOOL_LLD_BUILD) diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake index f01cba900..d4f636857 100644 --- a/cmake/Modules/AddCompilerRT.cmake +++ b/cmake/Modules/AddCompilerRT.cmake @@ -465,7 +465,7 @@ endmacro(add_compiler_rt_script src name) # DEPS <list of build deps> # CFLAGS <list of compile flags>) macro(add_custom_libcxx name prefix) - if(NOT COMPILER_RT_HAS_LIBCXX_SOURCES) + if(NOT COMPILER_RT_LIBCXX_PATH) message(FATAL_ERROR "libcxx not found!") endif() diff --git a/lib/msan/tests/CMakeLists.txt b/lib/msan/tests/CMakeLists.txt index 04428958e..b46023178 100644 --- a/lib/msan/tests/CMakeLists.txt +++ b/lib/msan/tests/CMakeLists.txt @@ -122,7 +122,7 @@ macro(add_msan_tests_for_arch arch kind cflags) endmacro() # We should only build MSan unit tests if we can build instrumented libcxx. -if(COMPILER_RT_CAN_EXECUTE_TESTS AND COMPILER_RT_HAS_LIBCXX_SOURCES) +if(COMPILER_RT_CAN_EXECUTE_TESTS AND COMPILER_RT_LIBCXX_PATH) foreach(arch ${MSAN_SUPPORTED_ARCH}) get_target_flags_for_arch(${arch} TARGET_CFLAGS) set(LIBCXX_PREFIX ${CMAKE_CURRENT_BINARY_DIR}/../libcxx_msan_${arch}) diff --git a/lib/tsan/CMakeLists.txt b/lib/tsan/CMakeLists.txt index b85762bb8..3697ecb21 100644 --- a/lib/tsan/CMakeLists.txt +++ b/lib/tsan/CMakeLists.txt @@ -203,7 +203,7 @@ if(COMPILER_RT_HAS_SYSROOT_FLAG AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD") endif() # Build libcxx instrumented with TSan. -if(COMPILER_RT_HAS_LIBCXX_SOURCES AND +if(COMPILER_RT_LIBCXX_PATH AND COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang" AND NOT ANDROID) set(libcxx_tsan_deps) diff --git a/test/msan/CMakeLists.txt b/test/msan/CMakeLists.txt index 171bcb961..b4532cfc9 100644 --- a/test/msan/CMakeLists.txt +++ b/test/msan/CMakeLists.txt @@ -25,7 +25,7 @@ if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND MSAN_TEST_DEPS msan) endif() -if(COMPILER_RT_INCLUDE_TESTS AND COMPILER_RT_HAS_LIBCXX_SOURCES) +if(COMPILER_RT_INCLUDE_TESTS AND COMPILER_RT_LIBCXX_PATH) configure_lit_site_cfg( ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg) diff --git a/test/tsan/CMakeLists.txt b/test/tsan/CMakeLists.txt index af329562d..2b1d3004b 100644 --- a/test/tsan/CMakeLists.txt +++ b/test/tsan/CMakeLists.txt @@ -7,7 +7,7 @@ endif() if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND TSAN_TEST_DEPS tsan) endif() -if(COMPILER_RT_HAS_LIBCXX_SOURCES AND +if(COMPILER_RT_LIBCXX_PATH AND COMPILER_RT_TEST_COMPILER_ID STREQUAL "Clang" AND NOT APPLE AND NOT ANDROID) list(APPEND TSAN_TEST_DEPS libcxx_tsan) |