summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2017-01-27 14:04:58 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2017-01-27 14:04:58 (GMT)
commit325c6153088c673569971958f107f6cb97b67c50 (patch)
tree751c3c03e0cc2f6bf96db80859fdb0beaf54f746 /Source
parent0ea578b498059340d575be263f5b6a91581f5ce5 (diff)
parent895f7f16a79428689a263ba5cd9a72647dc8e912 (diff)
downloadCMake-325c6153088c673569971958f107f6cb97b67c50.zip
CMake-325c6153088c673569971958f107f6cb97b67c50.tar.gz
CMake-325c6153088c673569971958f107f6cb97b67c50.tar.bz2
Merge topic 'genex-if'
895f7f16 Genex: Add `IF` generator expression
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorExpressionNode.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 398f95b..66202df 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -162,6 +162,27 @@ static const struct BoolNode : public cmGeneratorExpressionNode
}
} boolNode;
+static const struct IfNode : public cmGeneratorExpressionNode
+{
+ IfNode() {}
+
+ int NumExpectedParameters() const CM_OVERRIDE { return 3; }
+
+ std::string Evaluate(const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker*) const CM_OVERRIDE
+ {
+ if (parameters[0] != "1" && parameters[0] != "0") {
+ reportError(context, content->GetOriginalExpression(),
+ "First parameter to $<IF> must resolve to exactly one '0' "
+ "or '1' value.");
+ return std::string();
+ }
+ return parameters[0] == "1" ? parameters[1] : parameters[2];
+ }
+} ifNode;
+
static const struct StrEqualNode : public cmGeneratorExpressionNode
{
StrEqualNode() {}
@@ -1757,6 +1778,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(
nodeMap["UPPER_CASE"] = &upperCaseNode;
nodeMap["MAKE_C_IDENTIFIER"] = &makeCIdentifierNode;
nodeMap["BOOL"] = &boolNode;
+ nodeMap["IF"] = &ifNode;
nodeMap["ANGLE-R"] = &angle_rNode;
nodeMap["COMMA"] = &commaNode;
nodeMap["SEMICOLON"] = &semicolonNode;