llvm.org GIT mirror llvm / 0f056ec
[CMake] Don't override required compiler flags in the runtimes build Ensure that HandleLLVMOptions adds all necessary required flags, including -Wno-error when building with LLVM_ENABLE_WERROR enabled. Differential Revision: https://reviews.llvm.org/D58092 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@353790 91177308-0d34-0410-b5e6-96231b3b80d8 Petr Hosek 5 months ago
1 changed file(s) with 5 addition(s) and 13 deletion(s). Raw diff Collapse all Expand all
9292 set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
9393 endif()
9494
95 set(SAFE_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
96 set(SAFE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
97
9895 include(CheckLibraryExists)
9996 include(CheckCCompilerFlag)
10097
101 check_library_exists(c fopen "" LLVM_HAS_C_LIB)
102 check_c_compiler_flag(-nodefaultlibs LLVM_HAS_NODEFAULTLIBS_FLAG)
103 if(LLVM_HAS_NODEFAULTLIBS_FLAG)
104 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nodefaultlibs")
105 if(LLVM_HAS_C_LIB)
106 list(APPEND CMAKE_REQUIRED_LIBRARIES c)
107 endif()
108 endif()
98 # We don't have libc++ (yet).
99 set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
109100
110101 # Avoid checking whether the compiler is working.
111102 set(LLVM_COMPILER_CHECKED ON)
103 # Mark the compiler as compatible with GCC.
112104 # Enable warnings, otherwise -w gets added to the cflags by HandleLLVMOptions
113105 # resulting in unjustified successes by check_cxx_compiler_flag.
114106 set(LLVM_ENABLE_WARNINGS ON)
118110 include(HandleLLVMOptions)
119111 include(FindPythonInterp)
120112
121 set(CMAKE_REQUIRED_FLAGS ${SAFE_CMAKE_REQUIRED_FLAGS})
122 set(CMAKE_REQUIRED_LIBRARIES ${SAFE_CMAKE_REQUIRED_LIBRARIES})
113 # Remove the -nostdlib++ option we've added earlier.
114 string(REPLACE "-nostdlib++" "" CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
123115
124116 # This can be used to detect whether we're in the runtimes build.
125117 set(RUNTIMES_BUILD ON)