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

Arnaud Allard de Grandmaison arnaud.adegm at gmail.com
Thu Nov 21 15:22:12 PST 2013


On Thu, Nov 21, 2013 at 11:25 PM, Meador Inge <meadori at codesourcery.com>wrote:

> 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.
>

Well, in this case it is appended, so it plays nicely with the other
options.

I believe having this as an option will be good at least the beginning of
the transition, but it will soon enough change to be either on by default,
or even better, move to a check that the compiler does indeed support c++11
or bails otherwise.


>
> > 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 ?
>
>
Yep. Will add.


> >  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?
>

Copy / Paste from lines above. Will remove it.

Thanks for the comments.


>
> > +    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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131122/5dd0ddaa/attachment.html>


More information about the llvm-commits mailing list