[cmake-developers] target_compile_features remaining issues
Brad King
brad.king at kitware.com
Tue Apr 22 08:51:53 EDT 2014
On 04/21/2014 02:42 PM, Stephen Kelly wrote:
> Brad King wrote:
>
>> Later CMake learns about the -std=c++11 flag for that compiler and
>> honors the CXX_STANDARD request by passing it. Now the compiler
>> has its extensions disabled and the project fails to build. This
>> was due to an update in CMake, not the project.
>
> Is the same problem present with CMAKE_*_COMPILE_OPTIONS_{PIE,PIC,DLL} ?
Yes, but that is less fundamental than the language standard level.
>> We need a way for a project to say that it should not build unless
>> CMake knows how to nominally enable support for the given language
>> level.
>
> This requirement is inconsistent with what people keep asking me for (namely
> something like what the qmake CONFIG += c++11 does - enable a c++11 flag if
> known, and do nothing if not), and is inconsistent with the decay- topic.
Yes, and the CXX_STANDARD property in the decay- topic satisfies this
use case. We just need another interface to specify that the standard
request is a strict requirement.
> I think it be determined with code equivalent to
>
> if (target->GetProperty("CXX_STANDARD" == std::string("11")
> && !makefile->GetDefinition("CMAKE_CXX11_STANDARD_COMPILE_OPTION"))
> {
> // FATAL_ERROR
> }
Yes, so long as we set CMAKE_CXX11_STANDARD_COMPILE_OPTION to an empty
string on the compilers that support C++11 by default, like VS 12 (2013).
> We would need to know the compile options of compilers supported by existing
> versions of CMake, and ensure that the option is recorded for new
> CompilerIds and new releases of existing compiler ids too.
Yes, but for projects that have this requirement it is better to fail
due to a missing setting in CMake than work accidentally and fail later
when CMake is updated. Even with a missing setting in CMake it will
typically be possible to work around it locally by adding the setting
to the cache.
> However, I guess two different interfaces are needed if you want to ensure
> the 'require some notion of C++11' concept.
Perhaps another boolean property like CXX_STANDARD_REQUIRED would work.
Thanks,
-Brad
More information about the cmake-developers
mailing list