Features: FATAL_ERROR on compilers with no recorded features.
Users of the new target_compile_features command are expected to check the existence of the CMAKE_CXX_COMPILE_FEATURES variable before attempting to use it to require features.
This commit is contained in:
parent
447fbb3fac
commit
8d0b1ccac1
|
@ -4604,8 +4604,28 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
|
||||||
|
|
||||||
if (!featuresKnown || !*featuresKnown)
|
if (!featuresKnown || !*featuresKnown)
|
||||||
{
|
{
|
||||||
// We know of no features for the compiler at all.
|
cmOStringStream e;
|
||||||
return true;
|
if (error)
|
||||||
|
{
|
||||||
|
e << "no";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e << "No";
|
||||||
|
}
|
||||||
|
e << " known features for compiler\n\""
|
||||||
|
<< this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID")
|
||||||
|
<< "\"\nversion "
|
||||||
|
<< this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << ".";
|
||||||
|
if (error)
|
||||||
|
{
|
||||||
|
*error = e.str();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->IssueMessage(cmake::FATAL_ERROR, e.str());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> availableFeatures;
|
std::vector<std::string> availableFeatures;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,8 @@
|
||||||
|
CMake Error at NoSupportedCxxFeatures.cmake:3 \(target_compile_features\):
|
||||||
|
target_compile_features no known features for compiler
|
||||||
|
|
||||||
|
"[^"]*"
|
||||||
|
|
||||||
|
version *[.0-9]+\.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
add_library(no_features empty.cpp)
|
||||||
|
target_compile_features(no_features PRIVATE cxx_constexpr)
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,6 @@
|
||||||
|
CMake Error in CMakeLists.txt:
|
||||||
|
No known features for compiler
|
||||||
|
|
||||||
|
"[^"]*"
|
||||||
|
|
||||||
|
version *[.0-9]+\.
|
|
@ -0,0 +1,3 @@
|
||||||
|
|
||||||
|
add_library(no_features empty.cpp)
|
||||||
|
target_compile_features(no_features PRIVATE $<1:cxx_constexpr>)
|
|
@ -7,3 +7,14 @@ run_cmake(NotAFeature_OriginDebug)
|
||||||
run_cmake(NotAFeature_OriginDebugGenex)
|
run_cmake(NotAFeature_OriginDebugGenex)
|
||||||
run_cmake(NotAFeature_OriginDebugTransitive)
|
run_cmake(NotAFeature_OriginDebugTransitive)
|
||||||
run_cmake(NotAFeature_OriginDebug_target_compile_features)
|
run_cmake(NotAFeature_OriginDebug_target_compile_features)
|
||||||
|
|
||||||
|
run_cmake(generate_feature_list)
|
||||||
|
file(READ
|
||||||
|
"${RunCMake_BINARY_DIR}/generate_feature_list-build/features.txt"
|
||||||
|
FEATURES
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOT FEATURES)
|
||||||
|
run_cmake(NoSupportedCxxFeatures)
|
||||||
|
run_cmake(NoSupportedCxxFeaturesGenex)
|
||||||
|
endif()
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/features.txt"
|
||||||
|
"${CMAKE_CXX_COMPILE_FEATURES}"
|
||||||
|
)
|
Loading…
Reference in New Issue