CMake : optionaly enable LLVM to be compiled with -std=c++11 (default: off)
authorArnaud A. de Grandmaison <arnaud.adegm@gmail.com>
Tue, 26 Nov 2013 10:33:53 +0000 (10:33 +0000)
committerArnaud A. de Grandmaison <arnaud.adegm@gmail.com>
Tue, 26 Nov 2013 10:33:53 +0000 (10:33 +0000)
In some case, it may be required to build LLVM in C++11 mode, as some the subprojects (like lldb) requires it.

This mimics the autoconf behaviour.

However, given the discussions on the switch to C++11 of the codebase, this behaviour should evolve to default to C++11 with some checks of the compiler capabilities.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195727 91177308-0d34-0410-b5e6-96231b3b80d8

CMakeLists.txt
cmake/modules/HandleLLVMOptions.cmake
docs/CMake.rst

index 551b17828bcc6311ae89828b83e6e7e28f49e3a8..ce952f8997be7b330ecd3038570cfab642467278 100644 (file)
@@ -179,6 +179,7 @@ else( MSVC )
   option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
 endif()
 
+option(LLVM_ENABLE_CXX11 "Compile with C++11 enabled." OFF)
 option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
 option(LLVM_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
 
index bb41a58df2dd4f6e25ba9cabe8d959d105298c89..811ee9224352a381ab2d048e4ffbb3c4685607e6 100644 (file)
@@ -246,6 +246,10 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
   if (LLVM_ENABLE_WERROR)
     add_llvm_definitions( -Werror )
   endif (LLVM_ENABLE_WERROR)
+  if (LLVM_ENABLE_CXX11)
+    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)
 endif( MSVC )
 
 macro(append_common_sanitizer_flags)
index c9fe538c9dfa1e2067a939758eda667260f4bc9c..9fb4f489b44d6a7735efd63fe79fff83eec2a0f7 100644 (file)
@@ -211,6 +211,9 @@ LLVM-specific variables
 **LLVM_ENABLE_THREADS**:BOOL
   Build with threads support, if available. Defaults to ON.
 
+**LLVM_ENABLE_CXX11**:BOOL
+  Build in C++11 mode, if available. Defaults to OFF.
+
 **LLVM_ENABLE_ASSERTIONS**:BOOL
   Enables code assertions. Defaults to OFF if and only if ``CMAKE_BUILD_TYPE``
   is *Release*.