summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratorExpressionEvaluator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2013-06-26 13:02:49 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2013-06-26 13:02:49 (GMT)
commitc1631efa0eb0b33680ea73f745379eebf4d573a8 (patch)
treec1ba7e9d8d3d638c3ea3540cdbea891c08a63853 /Source/cmGeneratorExpressionEvaluator.cxx
parent22fbeaa14b5d79bc065b1c3061359c886167cc01 (diff)
parente6055284b347775ae1396725704778af0bfb56c7 (diff)
downloadCMake-c1631efa0eb0b33680ea73f745379eebf4d573a8.zip
CMake-c1631efa0eb0b33680ea73f745379eebf4d573a8.tar.gz
CMake-c1631efa0eb0b33680ea73f745379eebf4d573a8.tar.bz2
Merge topic 'version-compare-genex'
e605528 Add generator expressions for version comparision. 48bb48e De-duplicate version comparison code.
Diffstat (limited to 'Source/cmGeneratorExpressionEvaluator.cxx')
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx60
1 files changed, 60 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 701c547..d95006e 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -342,6 +342,60 @@ static const struct CXXCompilerIdNode : public CompilerIdNode
} cxxCompilerIdNode;
//----------------------------------------------------------------------------
+static const struct VersionGreaterNode : public cmGeneratorExpressionNode
+{
+ VersionGreaterNode() {}
+
+ virtual int NumExpectedParameters() const { return 2; }
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *,
+ const GeneratorExpressionContent *,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER,
+ parameters.front().c_str(),
+ parameters[1].c_str()) ? "1" : "0";
+ }
+} versionGreaterNode;
+
+//----------------------------------------------------------------------------
+static const struct VersionLessNode : public cmGeneratorExpressionNode
+{
+ VersionLessNode() {}
+
+ virtual int NumExpectedParameters() const { return 2; }
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *,
+ const GeneratorExpressionContent *,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
+ parameters.front().c_str(),
+ parameters[1].c_str()) ? "1" : "0";
+ }
+} versionLessNode;
+
+//----------------------------------------------------------------------------
+static const struct VersionEqualNode : public cmGeneratorExpressionNode
+{
+ VersionEqualNode() {}
+
+ virtual int NumExpectedParameters() const { return 2; }
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *,
+ const GeneratorExpressionContent *,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
+ parameters.front().c_str(),
+ parameters[1].c_str()) ? "1" : "0";
+ }
+} versionEqualNode;
+
+//----------------------------------------------------------------------------
static const struct ConfigurationNode : public cmGeneratorExpressionNode
{
ConfigurationNode() {}
@@ -1172,6 +1226,12 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
return &cCompilerIdNode;
else if (identifier == "CXX_COMPILER_ID")
return &cxxCompilerIdNode;
+ else if (identifier == "VERSION_GREATER")
+ return &versionGreaterNode;
+ else if (identifier == "VERSION_LESS")
+ return &versionLessNode;
+ else if (identifier == "VERSION_EQUAL")
+ return &versionEqualNode;
else if (identifier == "CONFIGURATION")
return &configurationNode;
else if (identifier == "CONFIG")