diff options
author | Brad King <brad.king@kitware.com> | 2013-10-07 19:41:39 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-10-07 19:41:39 (GMT) |
commit | 058af7a6ce3f9df093fae3d68484c1305c6c985a (patch) | |
tree | 330680e750b878048e783c810362146fb51025ae /Source | |
parent | ea3bb7ed9a8a2b278c1aa9c4435e9f12f515535c (diff) | |
parent | dcc00ece4b297f94974b84783805af9c01b6e681 (diff) | |
download | CMake-058af7a6ce3f9df093fae3d68484c1305c6c985a.zip CMake-058af7a6ce3f9df093fae3d68484c1305c6c985a.tar.gz CMake-058af7a6ce3f9df093fae3d68484c1305c6c985a.tar.bz2 |
Merge topic 'PLATFORM_ID-genex'
dcc00ec Genex: Add the PLATFORM_ID expression.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmDocumentGeneratorExpressions.h | 3 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionEvaluator.cxx | 35 |
2 files changed, 38 insertions, 0 deletions
diff --git a/Source/cmDocumentGeneratorExpressions.h b/Source/cmDocumentGeneratorExpressions.h index 46cd77e..7bab741 100644 --- a/Source/cmDocumentGeneratorExpressions.h +++ b/Source/cmDocumentGeneratorExpressions.h @@ -40,6 +40,9 @@ "is exported using export(), or when the target is used by another " \ "target in the same buildsystem. Expands to the empty string " \ "otherwise.\n" \ + " $<PLATFORM_ID> = The CMake-id of the platform " \ + " $<PLATFORM_ID:comp> = '1' if the The CMake-id of the " \ + "platform matches comp, otherwise '0'.\n" \ " $<C_COMPILER_ID> = The CMake-id of the C compiler " \ "used.\n" \ " $<C_COMPILER_ID:comp> = '1' if the CMake-id of the C " \ diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index abe4e70..7fd0fdc 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -438,6 +438,39 @@ static const struct CxxCompilerVersionNode : public CompilerVersionNode //---------------------------------------------------------------------------- +struct PlatformIdNode : public cmGeneratorExpressionNode +{ + PlatformIdNode() {} + + virtual int NumExpectedParameters() const { return ZeroOrMoreParameters; } + + std::string Evaluate(const std::vector<std::string> ¶meters, + cmGeneratorExpressionContext *context, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *) const + { + const char *platformId = context->Makefile ? + context->Makefile->GetSafeDefinition( + "CMAKE_SYSTEM_NAME") : ""; + if (parameters.size() == 0) + { + return platformId ? platformId : ""; + } + + if (!platformId) + { + return parameters.front().empty() ? "1" : "0"; + } + + if (cmsysString_strcasecmp(parameters.begin()->c_str(), platformId) == 0) + { + return "1"; + } + return "0"; + } +} platformIdNode; + +//---------------------------------------------------------------------------- static const struct VersionGreaterNode : public cmGeneratorExpressionNode { VersionGreaterNode() {} @@ -1356,6 +1389,8 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier) return &cCompilerVersionNode; else if (identifier == "CXX_COMPILER_VERSION") return &cxxCompilerVersionNode; + else if (identifier == "PLATFORM_ID") + return &platformIdNode; else if (identifier == "CONFIGURATION") return &configurationNode; else if (identifier == "CONFIG") |