1 # This CMake module is responsible for setting the standard library to libc++
2 # if the user has requested it.
4 if(NOT DEFINED LLVM_STDLIB_HANDLED)
5 set(LLVM_STDLIB_HANDLED ON)
7 if(CMAKE_COMPILER_IS_GNUCXX)
8 set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
10 set(LLVM_COMPILER_IS_GCC_COMPATIBLE OFF)
11 elseif( "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" )
12 set(LLVM_COMPILER_IS_GCC_COMPATIBLE ON)
15 function(append_if condition value)
17 foreach(variable ${ARGN})
18 set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
23 include(CheckCXXCompilerFlag)
24 if(LLVM_ENABLE_LIBCXX)
25 if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
26 check_cxx_compiler_flag("-stdlib=libc++" CXX_SUPPORTS_STDLIB)
27 append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_CXX_FLAGS)
28 append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_EXE_LINKER_FLAGS)
29 append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_SHARED_LINKER_FLAGS)
30 append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_MODULE_LINKER_FLAGS)
32 message(WARNING "Not sure how to specify libc++ for this compiler")