[cmake-developers] Portable STD_CXX11 target property?

Stephen Kelly steveire at gmail.com
Tue Jun 26 13:59:30 EDT 2012


Brad King wrote:
>> I have pushed a std-cxx-target-property branch to my gitorious repo to
>> illustrate the idea further, but I don't think there is any way to
>> specify which c++ standard to restrict to with MSVC, so the idea may
>> already be useless or dead in the water.
> 
> I'm not sure how to handle compilers that do not have
> an option for this.  Error?

It's a tricky question indeed. For MSVC I would say it should not be an 
error. For compilers which support no c++11 whatsoever (because they predate 
it by so long for example), I would also say not an error. 

> What if a future version
> of the compiler were to add an option, and a future
> version of CMake were to add support for the option?

To be clear, the scenario you mean is, for example, watcom doesn't currently 
support any c++11 switch, and then next year it gets -std=c++11, so we add a 
CMAKE_CXX_COMPILE_OPTIONS_STD_CXX11 setting to CMake for it?

> Then existing projects would build differently with
> a newer CMake.

Correct. Previously it wasn't as the buildsystem maintainer wanted (by their 
use of the CMAKE_STD_CXX11 setting), and with the newer CMake (and newer 
compiler) is is.

That kind of returns us to the question of whether it should be an error to 
use CMAKE_STD_CXX11 if a compiler doesn't provide a setting for it. It 
shouldn't be an error for the same reason that using 
POSITION_INDEPENDENT_CODE is not an error. We're not able to guess which 
compilers could possibly be used by the buildsystem which uses the setting.

Thanks,

Steve.





More information about the cmake-developers mailing list