[cmake-developers] target_compile_features remaining issues
Brad King
brad.king at kitware.com
Mon Apr 21 09:16:16 EDT 2014
On 04/20/2014 03:57 AM, Stephen Kelly wrote:
>> Perhaps we can have a feature name like "cxx_std_11" to require a
>> given standard level with an error if it is not available.
>
> Which compilers would provide that feature? GCC 4.8.1 and Clang 3.4
> (complete support)? GCC 4.7 (First release after ratification. Has compile
> flag -std=c++11)? GCC 4.3 (Has -std=c++0x)? MSVC? MSVC 2015 (speculative
> full support)? MSVC 2010 (partial support)? MSVC 2008 (Has override
> keyword)?
Consider a project that writes
set(CMAKE_CXX_STANDARD 11)
and someone tries to build with a compiler for which CMake does not
know about a -std=c++11 flag. Currently CMake generates no error
and "decays" to build with no flag at all. Let's say the project
happens to build without the flag because the compiler defaults to
a hypothetical -std=ext11 flag. Furthermore the project code
happens to (unintentionally) depend on that compiler's extensions
to c++11 to compile. Everything appears to work.
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.
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. Within that level the project could do its own preprocessor
tests or use WriteCompilerDetectionHeader to adapt to the subset
of the language level the compiler actually supports. However,
when CMake is asked to use a compiler it does not know supports
the language level at all, it should be an error.
-Brad
More information about the cmake-developers
mailing list