mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
Merge topic 'fix-C-standard-features'
fb3487a9Features: Fix C90 feature detection.6027798aFeatures: Allow setting standard dialect below the default.9d767810Features: Populate CMAKE_<LANG>_STANDARD_DEFAULT only for supported compilers.72537e44Features: Add dialect compile flags only if default is known.82c9d686AppleClang: Remove redundant UNIX condition.
This commit is contained in:
@@ -2205,7 +2205,7 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
|
||||
}
|
||||
const char* defaultStd
|
||||
= this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
|
||||
if (defaultStd && !*defaultStd)
|
||||
if (!defaultStd || !*defaultStd)
|
||||
{
|
||||
// This compiler has no notion of language standard levels.
|
||||
return;
|
||||
@@ -2272,18 +2272,32 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
|
||||
std::find(stds.begin(), stds.end(), standard);
|
||||
assert(stdIt != stds.end());
|
||||
|
||||
std::vector<std::string>::const_iterator defaultStdIt;
|
||||
if (defaultStd)
|
||||
std::vector<std::string>::const_iterator defaultStdIt =
|
||||
std::find(stds.begin(), stds.end(), defaultStd);
|
||||
if (defaultStdIt == stds.end())
|
||||
{
|
||||
defaultStdIt = std::find(stds.begin(), stds.end(), defaultStd);
|
||||
assert(defaultStdIt != stds.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultStdIt = stds.end() - 1;
|
||||
std::string e =
|
||||
"CMAKE_" + lang + "_STANDARD_DEFAULT is set to invalid value '" +
|
||||
std::string(defaultStd) + "'";
|
||||
this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, e);
|
||||
return;
|
||||
}
|
||||
|
||||
for ( ; stdIt <= defaultStdIt; ++stdIt)
|
||||
// Greater or equal because the standards are stored in
|
||||
// backward chronological order.
|
||||
if (stdIt >= defaultStdIt)
|
||||
{
|
||||
std::string option_flag =
|
||||
"CMAKE_" + lang + *stdIt
|
||||
+ "_" + type + "_COMPILE_OPTION";
|
||||
|
||||
const char *opt =
|
||||
target->GetMakefile()->GetRequiredDefinition(option_flag);
|
||||
this->AppendFlagEscape(flags, opt);
|
||||
return;
|
||||
}
|
||||
|
||||
for ( ; stdIt < defaultStdIt; ++stdIt)
|
||||
{
|
||||
std::string option_flag =
|
||||
"CMAKE_" + lang + *stdIt
|
||||
|
||||
Reference in New Issue
Block a user