summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorExpressionNode.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2018-11-06 16:27:03 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2018-11-19 22:02:06 (GMT)
commitb5f8113ca7796df47bcb04bcd77991885c3b1b07 (patch)
tree60304b3a34939b475a4314dd6dce11f34e2922f7 /Source/cmGeneratorExpressionNode.cxx
parent1dc85a6652bc8255ff7a9ef39028a7df45e3007b (diff)
downloadCMake-b5f8113ca7796df47bcb04bcd77991885c3b1b07.zip
CMake-b5f8113ca7796df47bcb04bcd77991885c3b1b07.tar.gz
CMake-b5f8113ca7796df47bcb04bcd77991885c3b1b07.tar.bz2
Genex: Add policy to handle empty list items in $<IN_LIST:...>
The old behavior of $<IN_LIST:...> is inconsistent with that of if(IN_LIST), in that it does not find an empty search item even if the list contains empty items. This change adds a new policy to correctly handle empty items and make the behavior more consistent with if(IN_LIST). Fixes: #18556
Diffstat (limited to 'Source/cmGeneratorExpressionNode.cxx')
-rw-r--r--Source/cmGeneratorExpressionNode.cxx35
1 files changed, 30 insertions, 5 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 49b97fb..eb3df16 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -283,14 +283,39 @@ static const struct InListNode : public cmGeneratorExpressionNode
std::string Evaluate(
const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
+ cmGeneratorExpressionContext* context,
const GeneratorExpressionContent* /*content*/,
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
- std::vector<std::string> values;
- cmSystemTools::ExpandListArgument(parameters[1], values);
- if (values.empty()) {
- return "0";
+ std::vector<std::string> values, checkValues;
+ bool check = false;
+ switch (context->LG->GetPolicyStatus(cmPolicies::CMP0085)) {
+ case cmPolicies::WARN:
+ if (parameters.front().empty()) {
+ check = true;
+ cmSystemTools::ExpandListArgument(parameters[1], checkValues, true);
+ }
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ cmSystemTools::ExpandListArgument(parameters[1], values);
+ if (check && values != checkValues) {
+ std::ostringstream e;
+ e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0085)
+ << "\nSearch Item:\n \"" << parameters.front()
+ << "\"\nList:\n \"" << parameters[1] << "\"\n";
+ context->LG->GetCMakeInstance()->IssueMessage(
+ cmake::AUTHOR_WARNING, e.str(), context->Backtrace);
+ return "0";
+ }
+ if (values.empty()) {
+ return "0";
+ }
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ cmSystemTools::ExpandListArgument(parameters[1], values, true);
+ break;
}
return std::find(values.cbegin(), values.cend(), parameters.front()) ==