[PATCH] CMake: optionaly enable LLVM to be compile with -std=c++11 (default: OFF)

Meador Inge meadori at codesourcery.com
Thu Nov 21 14:25:42 PST 2013


On 11/21/2013 04:04 PM, Arnaud Allard de Grandmaison wrote:

> In some cases, like when building llvm+lldb with cmake, llvm has to be built in
> c++11 mode. This patch adds the handling of this option. The default is OFF for
> now, but I suspect it will move to ON pretty soon given the discussions on the
> move to c++11 for the llvm codebase.

I am not sure why this is any better than -DCMAKE_CXX_FLAGS=-std=c++11, but
maybe someone else can argue that point.  Also, if/when we switch it seems like
the option is no longer useful since disabling means LLVM won't build after
folks start using C++11 features.

> diff --git a/CMakeLists.txt b/CMakeLists.txt
> index f43204f..40cc7b6 100644
> --- a/CMakeLists.txt
> +++ b/CMakeLists.txt
> @@ -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)

Should this be documented: http://llvm.org/docs/CMake.html ?

>  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 bb41a58..71a5d25 100644
> --- a/cmake/modules/HandleLLVMOptions.cmake
> +++ b/cmake/modules/HandleLLVMOptions.cmake
> @@ -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("-Werror -std=c++11" CXX_SUPPORTS_CXX11)

Why do you need to check for "-Werror" too?

> +    append_if(CXX_SUPPORTS_CXX11 "-std=c++11" CMAKE_CXX_FLAGS)
> +  endif (LLVM_ENABLE_CXX11)
>  endif( MSVC )
>  
>  macro(append_common_sanitizer_flags)
> -- 1.8.3.2


-- 
Meador Inge
CodeSourcery / Mentor Embedded



More information about the llvm-commits mailing list