[llvm] r195727 - CMake : optionaly enable LLVM to be compiled with -std=c++11 (default: off)

Arnaud A. de Grandmaison arnaud.adegm at gmail.com
Tue Nov 26 02:33:53 PST 2013

Author: aadg
Date: Tue Nov 26 04:33:53 2013
New Revision: 195727

URL: http://llvm.org/viewvc/llvm-project?rev=195727&view=rev
CMake : optionaly enable LLVM to be compiled with -std=c++11 (default: off)

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.


Modified: llvm/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/CMakeLists.txt?rev=195727&r1=195726&r2=195727&view=diff
--- llvm/trunk/CMakeLists.txt (original)
+++ llvm/trunk/CMakeLists.txt Tue Nov 26 04:33:53 2013
@@ -179,6 +179,7 @@ else( MSVC )
   option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
+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)

Modified: llvm/trunk/cmake/modules/HandleLLVMOptions.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/HandleLLVMOptions.cmake?rev=195727&r1=195726&r2=195727&view=diff
--- llvm/trunk/cmake/modules/HandleLLVMOptions.cmake (original)
+++ llvm/trunk/cmake/modules/HandleLLVMOptions.cmake Tue Nov 26 04:33:53 2013
@@ -246,6 +246,10 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE
     add_llvm_definitions( -Werror )
+    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 )

Modified: llvm/trunk/docs/CMake.rst
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/CMake.rst?rev=195727&r1=195726&r2=195727&view=diff
--- llvm/trunk/docs/CMake.rst (original)
+++ llvm/trunk/docs/CMake.rst Tue Nov 26 04:33:53 2013
@@ -211,6 +211,9 @@ LLVM-specific variables
   Build with threads support, if available. Defaults to ON.
+  Build in C++11 mode, if available. Defaults to OFF.
   Enables code assertions. Defaults to OFF if and only if ``CMAKE_BUILD_TYPE``
   is *Release*.

More information about the llvm-commits mailing list