Commit 3ce57e3b authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'fix-lang-std-option-list'

cef77f06 Allow language extensions without any standard to use a list of options
74e33711 Merge branch 'backport-fix-lang-std-option-list' into fix-lang-std-option-list
fca05461 cmLocalGenerator: Explain standard flag selection logic in comments
218ce158 Features: Fix support for a list of language standard options
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !1059
parents 96041907 cef77f06
......@@ -1563,7 +1563,11 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
"CMAKE_" + lang + "_EXTENSION_COMPILE_OPTION";
if (const char* opt =
target->Target->GetMakefile()->GetDefinition(option_flag)) {
this->AppendFlagEscape(flags, opt);
std::vector<std::string> optVec;
cmSystemTools::ExpandListArgument(opt, optVec);
for (size_t i = 0; i < optVec.size(); ++i) {
this->AppendFlagEscape(flags, optVec[i]);
}
}
}
return;
......@@ -1637,25 +1641,38 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
return;
}
// Greater or equal because the standards are stored in
// backward chronological order.
// If the standard requested is older than the compiler's default
// then we need to use a flag to change it. The comparison is
// 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->Target->GetMakefile()->GetRequiredDefinition(option_flag);
this->AppendFlagEscape(flags, opt);
std::vector<std::string> optVec;
cmSystemTools::ExpandListArgument(opt, optVec);
for (size_t i = 0; i < optVec.size(); ++i) {
this->AppendFlagEscape(flags, optVec[i]);
}
return;
}
// The standard requested is at least as new as the compiler's default,
// and the standard request is not required. Decay to the newest standard
// for which a flag is defined.
for (; stdIt < defaultStdIt; ++stdIt) {
std::string option_flag =
"CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION";
if (const char* opt =
target->Target->GetMakefile()->GetDefinition(option_flag)) {
this->AppendFlagEscape(flags, opt);
std::vector<std::string> optVec;
cmSystemTools::ExpandListArgument(opt, optVec);
for (size_t i = 0; i < optVec.size(); ++i) {
this->AppendFlagEscape(flags, optVec[i]);
}
return;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment