[cmake-developers] C++11 and target_compiler_feature proposal
Stephen Kelly
steveire at gmail.com
Thu Oct 10 20:26:56 EDT 2013
Rolf Eike Beer wrote:
> The idea that we agreed upon (or basically: that Steve proposed and which
> I didn't fully understand until today) is that there will be a list of
> supported features for every compiler and version. Usually CMake will just
> use that list when it goes to determine if it could satisfy the requested
> features from the user. If the user believes the list is wrong or simply
> has a compiler currently not in the list he can request to do
> test-compiles for everything requested and use that results.
The user can also simply set CMAKE_CXX11_COMPILER_FEATURE to different
content, if desired. No need to run a try_compile in that scenario.
> In fact the
> testcase on all platforms will just do exactly that: request all features
> and compare it with the static list. So basically this is just a
> pre-populated cache.
The test results and the 'cached' results won't be exactly the same though,
so the test should not check for exact-match, but just affirmation. Eg:
if (CMAKE_CXX11_COMPILER_FEATURE CONTAINS constexpr) # CONTAINS is pseudo
test_for(constexpr)
endif()
Not
test_for(constexpr Result)
if (Result)
if(NOT CMAKE_CXX11_COMPILER_FEATURE CONTAINS constexpr)
message(SEND_ERROR "mismatch")
endif()
endif()
because the try_compile and the CMAKE_CXX11_COMPILER_FEATURE will disagree
for GCC 4.5 and the constexpr feature.
> Steve, anything important I missed?
I can't think of anything.
Thanks,
Steve.
More information about the cmake-developers
mailing list