llvm.org GIT mirror llvm / ed85367
[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 Petr Hosek 3 years ago
1 changed file(s) with 19 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
2828 # CMake module path.
2929 list(INSERT CMAKE_MODULE_PATH 0
3030 "${CMAKE_CURRENT_SOURCE_DIR}/../cmake"
31 "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/Modules"
31 "${CMAKE_CURRENT_SOURCE_DIR}/../cmake/modules"
3232 "${LLVM_BINARY_DIR}/lib/cmake/llvm"
3333 )
3434
6464 set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
6565 endif()
6666
67 set(SAFE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
68 set(SAFE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
69
70 include(CheckLibraryExists)
71 include(CheckCCompilerFlag)
72
73 check_library_exists(c fopen "" LLVM_HAS_C_LIB)
74 check_c_compiler_flag(-nodefaultlibs LLVM_HAS_NODEFAULTLIBS_FLAG)
75 if(LLVM_HAS_NODEFAULTLIBS_FLAG)
76 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
77 if(LLVM_HAS_C_LIB)
78 list(APPEND CMAKE_REQUIRED_LIBRARIES c)
79 endif()
80 endif()
81
6782 # Handle common options used by all runtimes.
6883 include(AddLLVM)
6984 include(HandleLLVMOptions)
85
86 set(CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS})
87 set(CMAKE_REQUIRED_LIBRARIES ${SAFE_CMAKE_REQUIRED_LIBRARIES})
7088
7189 foreach(entry ${runtimes})
7290 get_filename_component(projName ${entry} NAME)