diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-06-11 07:53:10 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-06-12 12:09:36 (GMT) |
commit | e6055284b347775ae1396725704778af0bfb56c7 (patch) | |
tree | a35bffc4faadf289d7239796edbc2104f74e8f2d /Source | |
parent | 48bb48e114b7141b63e9c905f0258531c6b78cb1 (diff) | |
download | CMake-e6055284b347775ae1396725704778af0bfb56c7.zip CMake-e6055284b347775ae1396725704778af0bfb56c7.tar.gz CMake-e6055284b347775ae1396725704778af0bfb56c7.tar.bz2 |
Add generator expressions for version comparision.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmDocumentGeneratorExpressions.h | 6 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionEvaluator.cxx | 60 |
2 files changed, 66 insertions, 0 deletions
diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h index a8b3847..84f4af5 100644 --- a/Source/cmDocumentGeneratorExpressions.h +++ b/Source/cmDocumentGeneratorExpressions.h @@ -48,6 +48,12 @@ "used.\n" \ " $<CXX_COMPILER_ID:comp> = '1' if the CMake-id of the CXX " \ "compiler matches comp, otherwise '0'.\n" \ + " $<VERSION_GREATER:v1,v2> = '1' if v1 is a version greater than " \ + "v2, else '0'.\n" \ + " $<VERSION_LESS:v1,v2> = '1' if v1 is a version less than v2, " \ + "else '0'.\n" \ + " $<VERSION_EQUAL:v1,v2> = '1' if v1 is the same version as v2, " \ + "else '0'.\n" \ " $<TARGET_FILE:tgt> = main file (.exe, .so.1.2, .a)\n" \ " $<TARGET_LINKER_FILE:tgt> = file used to link (.a, .lib, .so)\n" \ " $<TARGET_SONAME_FILE:tgt> = file with soname (.so.3)\n" \ diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 28f749d..1804691 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -345,6 +345,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> ¶meters, + 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> ¶meters, + 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> ¶meters, + 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() {} @@ -1169,6 +1223,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") |