diff options
author | Chuck Atkins <chuck.atkins@kitware.com> | 2016-08-05 18:11:46 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-08-09 13:30:34 (GMT) |
commit | 02d177c9cc05514baccfa530ab85eec65374fbcb (patch) | |
tree | 2fbef7a16d4acac2b3b7218ef1abd16690566d9a /Source/cmGeneratorExpressionNode.cxx | |
parent | 93b705a396c23f771ba203efb6f2f4934ae027b7 (diff) | |
download | CMake-02d177c9cc05514baccfa530ab85eec65374fbcb.zip CMake-02d177c9cc05514baccfa530ab85eec65374fbcb.tar.gz CMake-02d177c9cc05514baccfa530ab85eec65374fbcb.tar.bz2 |
Add additional <= and >= comparison operators
This adds the LESS_EQUAL, GREATER_EQUAL, and associated STR and VERSION
equivalents to use the combined <= and >= functionality.
Diffstat (limited to 'Source/cmGeneratorExpressionNode.cxx')
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index ca7250b..6e2b16a 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -545,6 +545,25 @@ static const struct VersionGreaterNode : public cmGeneratorExpressionNode } } versionGreaterNode; +static const struct VersionGreaterEqNode : public cmGeneratorExpressionNode +{ + VersionGreaterEqNode() {} + + int NumExpectedParameters() const CM_OVERRIDE { return 2; } + + std::string Evaluate(const std::vector<std::string>& parameters, + cmGeneratorExpressionContext*, + const GeneratorExpressionContent*, + cmGeneratorExpressionDAGChecker*) const CM_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() {} @@ -564,6 +583,25 @@ static const struct VersionLessNode : public cmGeneratorExpressionNode } } versionLessNode; +static const struct VersionLessEqNode : public cmGeneratorExpressionNode +{ + VersionLessEqNode() {} + + int NumExpectedParameters() const CM_OVERRIDE { return 2; } + + std::string Evaluate(const std::vector<std::string>& parameters, + cmGeneratorExpressionContext*, + const GeneratorExpressionContent*, + cmGeneratorExpressionDAGChecker*) const CM_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() {} @@ -1641,7 +1679,9 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode( nodeMap["C_COMPILER_ID"] = &cCompilerIdNode; nodeMap["CXX_COMPILER_ID"] = &cxxCompilerIdNode; nodeMap["VERSION_GREATER"] = &versionGreaterNode; + nodeMap["VERSION_GREATER_EQUAL"] = &versionGreaterEqNode; nodeMap["VERSION_LESS"] = &versionLessNode; + nodeMap["VERSION_LESS_EQUAL"] = &versionLessEqNode; nodeMap["VERSION_EQUAL"] = &versionEqualNode; nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode; nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode; |