Features: Add dialect compile flags only if default is known.
The CMAKE_<LANG>_STANDARD_DEFAULT variable indicates whether the compiler has any notion of standard levels and that CMake knows about them. If no language standard levels are available, skip all logic to attempt to add a flag for the level. Also fail with an internal error if a bad default value is set.
This commit is contained in:
parent
82c9d6868b
commit
72537e4436
|
@ -2209,7 +2209,7 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
|
||||||
}
|
}
|
||||||
const char* defaultStd
|
const char* defaultStd
|
||||||
= this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
|
= this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
|
||||||
if (defaultStd && !*defaultStd)
|
if (!defaultStd || !*defaultStd)
|
||||||
{
|
{
|
||||||
// This compiler has no notion of language standard levels.
|
// This compiler has no notion of language standard levels.
|
||||||
return;
|
return;
|
||||||
|
@ -2276,15 +2276,15 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
|
||||||
std::find(stds.begin(), stds.end(), standard);
|
std::find(stds.begin(), stds.end(), standard);
|
||||||
assert(stdIt != stds.end());
|
assert(stdIt != stds.end());
|
||||||
|
|
||||||
std::vector<std::string>::const_iterator defaultStdIt;
|
std::vector<std::string>::const_iterator defaultStdIt =
|
||||||
if (defaultStd)
|
std::find(stds.begin(), stds.end(), defaultStd);
|
||||||
|
if (defaultStdIt == stds.end())
|
||||||
{
|
{
|
||||||
defaultStdIt = std::find(stds.begin(), stds.end(), defaultStd);
|
std::string e =
|
||||||
assert(defaultStdIt != stds.end());
|
"CMAKE_" + lang + "_STANDARD_DEFAULT is set to invalid value '" +
|
||||||
}
|
std::string(defaultStd) + "'";
|
||||||
else
|
this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, e);
|
||||||
{
|
return;
|
||||||
defaultStdIt = stds.end() - 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( ; stdIt <= defaultStdIt; ++stdIt)
|
for ( ; stdIt <= defaultStdIt; ++stdIt)
|
||||||
|
|
Loading…
Reference in New Issue