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 value)
16 foreach(variable ${ARGN})
17 set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
21 include(CheckCXXCompilerFlag)
22 if(LLVM_ENABLE_LIBCXX)
23 if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
24 check_cxx_compiler_flag("-stdlib=libc++" CXX_SUPPORTS_STDLIB)
25 if(CXX_SUPPORTS_STDLIB)
26 append("-stdlib=libc++"
27 CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
28 CMAKE_MODULE_LINKER_FLAGS)
29 if(LLVM_ENABLE_LIBCXXABI)
31 CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
32 CMAKE_MODULE_LINKER_FLAGS)
35 message(WARNING "Can't specify libc++ with '-stdlib='")
38 message(WARNING "Not sure how to specify libc++ for this compiler")