[cmake-developers] C++11 and target_compiler_feature proposal

Stephen Kelly steveire at gmail.com
Fri Oct 11 10:56:04 EDT 2013


Brad King wrote:

> 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 assume so. The only flag I'm aware of for XL is -qlanglvl=extended0x, and 
that is equivalent to -std=c++11 afaik. What are you referring to 
specifically?
 
>> 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.

Hmm, this might be a sticking point. 

I'm in favor of sticking close to the defaults of the compiler. The user 
shouldn't have to tell CMake to use the extension if that is the default for 
the compiler anyway, just as a penalty for telling CMake about requiring 
variadic templates.

Thanks,

Steve.





More information about the cmake-developers mailing list