[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 16:11:29 PST 2013


The patch was attempting to mimic autoconf's behaviour...

I am not sure to follow you Eric : do you mean this should not be an option
any more, and must always be set in autoconf and cmake ? It would then just
be a question of using the c++1 features (or not). In this case, I believe
a should at least check that the compiler supports '-std=c++11' (or a
different wording for non gcc compatible compilers). This would also be the
right place to check the compiler is a version recent enough as well to
build llvm --- in accrodance with c++11 switch huge discussion.


On Fri, Nov 22, 2013 at 12:26 AM, Eric Christopher <echristo at gmail.com>wrote:

> On Thu, Nov 21, 2013 at 2: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.
> >
>
> *shrug* We can remove the option at that point. I've had one in the
> autoconf side for the last few years.
>
> -eric
>
> >> 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
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131122/23efc46d/attachment.html>


More information about the llvm-commits mailing list