[cmake-developers] C++11 and target_compiler_feature proposal
Brad King
brad.king at kitware.com
Fri Oct 11 09:15:52 EDT 2013
On 10/10/2013 08:07 PM, Stephen Kelly wrote:
> So, I think this is a two dimensional calculation. There is a standard axis
> and a extension axis for the compiler flag, for GCC and clang at least.
Yes.
> if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
> set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
> set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
> endif()
Will this work for XL too?
> I wonder if we should always use the extension flag, unless otherwise
> specified with set(CMAKE_STRICT_CXX_STANDARD ON)?
>
> Because gnu++98 is the GCC default, someone could be using 'gnu template
> instantiation' in existing code, and then uses CMake to specify the need for
> variadic_templates, so we add -std=c++11 and boom - no more gnu extensions.
As you point out the user would have to have modified the project anyway
so at that point they can specify explicitly the "default" extensions
they were using before.
-Brad
More information about the cmake-developers
mailing list