From 1abc3c0b7fe517ac7fc0d215c0e93003518e6270 Mon Sep 17 00:00:00 2001 From: Jean-Daniel Dupas Date: Mon, 6 Jan 2014 18:27:27 +0000 Subject: [PATCH] Introduce a cmake LLVM_ENABLE_LIBCXX build parameter to compile using libc++ instead of the system default Summary: This parameter is required to build C++11 projects (like lld or lldb) on OS X as the default STL does not provide c++ classes. CC: llvm-commits, triton Differential Revision: http://llvm-reviews.chandlerc.com/D2381 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198625 91177308-0d34-0410-b5e6-96231b3b80d8 --- CMakeLists.txt | 1 + cmake/modules/HandleLLVMOptions.cmake | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56e83289a45..ad31686aafc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -182,6 +182,7 @@ else( MSVC ) endif() option(LLVM_ENABLE_CXX11 "Compile with C++11 enabled." OFF) +option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF) option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON) option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF) diff --git a/cmake/modules/HandleLLVMOptions.cmake b/cmake/modules/HandleLLVMOptions.cmake index 38dacb7b887..21d2cd67406 100644 --- a/cmake/modules/HandleLLVMOptions.cmake +++ b/cmake/modules/HandleLLVMOptions.cmake @@ -253,6 +253,13 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE ) check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11) append_if(CXX_SUPPORTS_CXX11 "-std=c++11" CMAKE_CXX_FLAGS) endif (LLVM_ENABLE_CXX11) + if(LLVM_ENABLE_LIBCXX) + check_cxx_compiler_flag("-stdlib=libc++" CXX_SUPPORTS_STDLIB) + append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_CXX_FLAGS) + append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_EXE_LINKER_FLAGS) + append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_SHARED_LINKER_FLAGS) + append_if(CXX_SUPPORTS_STDLIB "-stdlib=libc++" CMAKE_MODULE_LINKER_FLAGS) + endif () endif( MSVC ) macro(append_common_sanitizer_flags)