diff options
author | Petr Hosek <phosek@chromium.org> | 2017-04-13 21:29:03 +0000 |
---|---|---|
committer | Petr Hosek <phosek@chromium.org> | 2017-04-13 21:29:03 +0000 |
commit | ed853677385d41a2149f3fc386cfeb407a9b9709 (patch) | |
tree | 4ad3f91a7132f86313ff880ff384c4e0a374f3d7 /runtimes | |
parent | 10683346a57eaec13c4d6885ce845e4bc392441f (diff) |
[CMake][runtimes] Use -nodefaultlibs for the runtimes build
We may not have a working C++ standard library at this point so we
shouldn't rely on it when running CMake checks.
Differential Revision: https://reviews.llvm.org/D31942
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300260 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtimes')
-rw-r--r-- | runtimes/CMakeLists.txt | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt index 8be1d9e7c52..ef56fa1b936 100644 --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -29,7 +29,7 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) # CMake module path. list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_SOURCE_DIR}/../cmake" - "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Modules" + "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules" "${LLVM_BINARY_DIR}/lib/cmake/llvm" ) @@ -65,10 +65,28 @@ if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR}) set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "") endif() + set(SAFE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) + set(SAFE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES}) + + include(CheckLibraryExists) + include(CheckCCompilerFlag) + + check_library_exists(c fopen "" LLVM_HAS_C_LIB) + check_c_compiler_flag(-nodefaultlibs LLVM_HAS_NODEFAULTLIBS_FLAG) + if(LLVM_HAS_NODEFAULTLIBS_FLAG) + set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs") + if(LLVM_HAS_C_LIB) + list(APPEND CMAKE_REQUIRED_LIBRARIES c) + endif() + endif() + # Handle common options used by all runtimes. include(AddLLVM) include(HandleLLVMOptions) + set(CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS}) + set(CMAKE_REQUIRED_LIBRARIES ${SAFE_CMAKE_REQUIRED_LIBRARIES}) + foreach(entry ${runtimes}) get_filename_component(projName ${entry} NAME) |