[cmake-developers] c++ feature detection and usage requirements (was: Please review CXXFeatures.cmake)
Brad King
brad.king at kitware.com
Tue Aug 27 13:16:41 EDT 2013
On 08/15/2013 08:37 AM, Stephen Kelly wrote:
> target_compiler_feature(<target> <PUBLIC|PRIVATE>
> REQUIRED <feature1> [<feature2> ...])
> target_compiler_feature(<target> <PUBLIC|PRIVATE>
> OPTIONAL <feature> DEFINE <define_name>)
Doesn't this require the language (CXX) to be specified somewhere?
Perhaps the feature names should start with <lang>_ e.g. CXX_final.
> This is better in many noteworthy ways to the cxx11 topic in the stage.
>
> Brad, do you have any response to any part of anything I wrote about that
> topic?
The detection of features available for a given compiler and the
usage requirements to require/enable them are orthogonal issues
on the implementation side but may overlap in the CMake interface.
I like your proposed target_compiler_feature feature for the latter.
As for detection, I like that Eike's solution will work without
hard-coding knowledge for every compiler. I also like hard-coding
the answers for known compilers whose id/version can be reliably
detected to avoid needless try_compile calls on every project.
Furthermore, your argument about partial implementations of features
versus the documented later version introducing them is important.
It is also nice to have it builtin to the platform information
modules for use with target_compiler_feature. I'd like to see a
solution that hard-codes the answers when known but also knows when
it does not know and can run a detection step. This will be tricky
because the platform files are too early to use try_compile so some
kind of on-demand check may be needed. Ideas?
I think Eike's topic will be a fantastic reference for the test
case code and the expected results and will be useful for you to
write a more complete solution. I like the target_compiler_feature
syntax better than find_package(CXXFeatures), but something like the
latter may be needed to make CMake-time decisions based on available
features rather than waiting until preprocessing time.
-Brad
More information about the cmake-developers
mailing list