Jordan Rose | 1b7969e | 2014-02-05 00:02:37 +0000 | [diff] [blame] | 1 | # This CMake module is responsible for setting the standard library to libc++ |
| 2 | # if the user has requested it. |
| 3 | |
John Brawn | a933c2a | 2015-09-29 14:33:58 +0000 | [diff] [blame] | 4 | include(DetermineGCCCompatible) |
| 5 | |
Jordan Rose | 1b7969e | 2014-02-05 00:02:37 +0000 | [diff] [blame] | 6 | if(NOT DEFINED LLVM_STDLIB_HANDLED) |
| 7 | set(LLVM_STDLIB_HANDLED ON) |
| 8 | |
Chandler Carruth | 24a6fb0 | 2015-03-07 10:30:34 +0000 | [diff] [blame] | 9 | function(append value) |
| 10 | foreach(variable ${ARGN}) |
| 11 | set(${variable} "${${variable}} ${value}" PARENT_SCOPE) |
| 12 | endforeach(variable) |
Jordan Rose | 1b7969e | 2014-02-05 00:02:37 +0000 | [diff] [blame] | 13 | endfunction() |
| 14 | |
| 15 | include(CheckCXXCompilerFlag) |
Shoaib Meenai | 210f169 | 2018-04-24 19:47:39 +0000 | [diff] [blame] | 16 | include(CheckLinkerFlag) |
Jordan Rose | 1b7969e | 2014-02-05 00:02:37 +0000 | [diff] [blame] | 17 | if(LLVM_ENABLE_LIBCXX) |
| 18 | if(LLVM_COMPILER_IS_GCC_COMPATIBLE) |
Shoaib Meenai | 210f169 | 2018-04-24 19:47:39 +0000 | [diff] [blame] | 19 | 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 Carruth | 24a6fb0 | 2015-03-07 10:30:34 +0000 | [diff] [blame] | 22 | append("-stdlib=libc++" |
| 23 | CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS |
| 24 | CMAKE_MODULE_LINKER_FLAGS) |
Chandler Carruth | 24a6fb0 | 2015-03-07 10:30:34 +0000 | [diff] [blame] | 25 | else() |
| 26 | message(WARNING "Can't specify libc++ with '-stdlib='") |
| 27 | endif() |
Jordan Rose | 1b7969e | 2014-02-05 00:02:37 +0000 | [diff] [blame] | 28 | else() |
| 29 | message(WARNING "Not sure how to specify libc++ for this compiler") |
| 30 | endif() |
| 31 | endif() |
| 32 | endif() |