summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorLeonid Pospelov <pospelovlm@yandex.ru>2019-04-15 12:38:16 (GMT)
committerBrad King <brad.king@kitware.com>2019-04-22 14:41:28 (GMT)
commit36f36d6a49976527a13a77d1ffff1fcdc5c3f5ba (patch)
treed69ad5ea3a3bb226945b8a33a682126807984377 /Source
parent3f57787dffa629b7c10ca2a02229b7e1a4bfe1f9 (diff)
downloadCMake-36f36d6a49976527a13a77d1ffff1fcdc5c3f5ba.zip
CMake-36f36d6a49976527a13a77d1ffff1fcdc5c3f5ba.tar.gz
CMake-36f36d6a49976527a13a77d1ffff1fcdc5c3f5ba.tar.bz2
cmGeneratorExpressionNode: add VersionNode
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGeneratorExpressionNode.cxx94
1 files changed, 10 insertions, 84 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 5db46dd..306c9c7 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -792,9 +792,10 @@ struct PlatformIdNode : public cmGeneratorExpressionNode
}
} platformIdNode;
-static const struct VersionGreaterNode : public cmGeneratorExpressionNode
+template <cmSystemTools::CompareOp Op>
+struct VersionNode : public cmGeneratorExpressionNode
{
- VersionGreaterNode() {} // NOLINT(modernize-use-equals-default)
+ VersionNode() {} // NOLINT(modernize-use-equals-default)
int NumExpectedParameters() const override { return 2; }
@@ -804,93 +805,18 @@ static const struct VersionGreaterNode : public cmGeneratorExpressionNode
const GeneratorExpressionContent* /*content*/,
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
{
- return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER,
- parameters.front().c_str(),
- parameters[1].c_str())
- ? "1"
- : "0";
- }
-} versionGreaterNode;
-
-static const struct VersionGreaterEqNode : public cmGeneratorExpressionNode
-{
- VersionGreaterEqNode() {} // NOLINT(modernize-use-equals-default)
-
- int NumExpectedParameters() const override { return 2; }
-
- std::string Evaluate(
- const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
- {
- return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL,
- parameters.front().c_str(),
- parameters[1].c_str())
- ? "1"
- : "0";
- }
-} versionGreaterEqNode;
-
-static const struct VersionLessNode : public cmGeneratorExpressionNode
-{
- VersionLessNode() {} // NOLINT(modernize-use-equals-default)
-
- int NumExpectedParameters() const override { return 2; }
-
- std::string Evaluate(
- const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
- {
- return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
- parameters.front().c_str(),
+ return cmSystemTools::VersionCompare(Op, parameters.front().c_str(),
parameters[1].c_str())
? "1"
: "0";
}
-} versionLessNode;
-
-static const struct VersionLessEqNode : public cmGeneratorExpressionNode
-{
- VersionLessEqNode() {} // NOLINT(modernize-use-equals-default)
-
- int NumExpectedParameters() const override { return 2; }
-
- std::string Evaluate(
- const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
- {
- return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS_EQUAL,
- parameters.front().c_str(),
- parameters[1].c_str())
- ? "1"
- : "0";
- }
-} versionLessEqNode;
-
-static const struct VersionEqualNode : public cmGeneratorExpressionNode
-{
- VersionEqualNode() {} // NOLINT(modernize-use-equals-default)
-
- int NumExpectedParameters() const override { return 2; }
+};
- std::string Evaluate(
- const std::vector<std::string>& parameters,
- cmGeneratorExpressionContext* /*context*/,
- const GeneratorExpressionContent* /*content*/,
- cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
- {
- return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
- parameters.front().c_str(),
- parameters[1].c_str())
- ? "1"
- : "0";
- }
-} versionEqualNode;
+static const VersionNode<cmSystemTools::OP_GREATER> versionGreaterNode;
+static const VersionNode<cmSystemTools::OP_GREATER_EQUAL> versionGreaterEqNode;
+static const VersionNode<cmSystemTools::OP_LESS> versionLessNode;
+static const VersionNode<cmSystemTools::OP_LESS_EQUAL> versionLessEqNode;
+static const VersionNode<cmSystemTools::OP_EQUAL> versionEqualNode;
static const struct LinkOnlyNode : public cmGeneratorExpressionNode
{