blob: a0706d8e0846a52c310d5f8d80b902f467651101 [file] [log] [blame]
Jordan Rose1b7969e2014-02-05 00:02:37 +00001# This CMake module is responsible for setting the standard library to libc++
2# if the user has requested it.
3
John Brawna933c2a2015-09-29 14:33:58 +00004include(DetermineGCCCompatible)
5
Jordan Rose1b7969e2014-02-05 00:02:37 +00006if(NOT DEFINED LLVM_STDLIB_HANDLED)
7 set(LLVM_STDLIB_HANDLED ON)
8
Chandler Carruth24a6fb02015-03-07 10:30:34 +00009 function(append value)
10 foreach(variable ${ARGN})
11 set(${variable} "${${variable}} ${value}" PARENT_SCOPE)
12 endforeach(variable)
Jordan Rose1b7969e2014-02-05 00:02:37 +000013 endfunction()
14
15 include(CheckCXXCompilerFlag)
Shoaib Meenai210f1692018-04-24 19:47:39 +000016 include(CheckLinkerFlag)
Jordan Rose1b7969e2014-02-05 00:02:37 +000017 if(LLVM_ENABLE_LIBCXX)
18 if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
Shoaib Meenai210f1692018-04-24 19:47:39 +000019 check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB)
20 check_linker_flag("-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
21 if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB)
Chandler Carruth24a6fb02015-03-07 10:30:34 +000022 append("-stdlib=libc++"
23 CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
24 CMAKE_MODULE_LINKER_FLAGS)
Chandler Carruth24a6fb02015-03-07 10:30:34 +000025 else()
26 message(WARNING "Can't specify libc++ with '-stdlib='")
27 endif()
Jordan Rose1b7969e2014-02-05 00:02:37 +000028 else()
29 message(WARNING "Not sure how to specify libc++ for this compiler")
30 endif()
31 endif()
32endif()