summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-11-20 21:40:29 +0100
committerStephen Kelly <steveire@gmail.com>2013-11-27 19:06:12 +0100
commit1242f4e56924ddfb7f954d820918c89c333e1dc5 (patch)
treeb4f7d0437efd24e0508e9f998a082ff576c3c03c
parent754b3212720d0846b1b5847fae888bc79bb8cfc3 (diff)
downloadcmake-1242f4e56924ddfb7f954d820918c89c333e1dc5.tar.gz
Genex: Add {UPPER,LOWER}_CASE and MAKE_C_IDENTIFIER.
-rw-r--r--Help/manual/cmake-generator-expressions.7.rst6
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx48
-rw-r--r--Tests/GeneratorExpression/CMakeLists.txt3
-rw-r--r--Tests/GeneratorExpression/check-part3.cmake3
4 files changed, 60 insertions, 0 deletions
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index bd9e7c20a6..ed28abd31c 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -178,3 +178,9 @@ property is non-empty::
Content of ``...`` when the property is exported using :command:`export`, or
when the target is used by another target in the same buildsystem. Expands to
the empty string otherwise.
+``$<LOWER_CASE:...>``
+ Content of ``...`` converted to lower case.
+``$<UPPER_CASE:...>``
+ Content of ``...`` converted to upper case.
+``$<MAKE_C_IDENTIFIER:...>``
+ Content of ``...`` converted to a C identifier.
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 17bf041ff9..0f8c4e392f 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -199,6 +199,48 @@ static const struct StrEqualNode : public cmGeneratorExpressionNode
} strEqualNode;
//----------------------------------------------------------------------------
+static const struct LowerCaseNode : public cmGeneratorExpressionNode
+{
+ LowerCaseNode() {}
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *,
+ const GeneratorExpressionContent *,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ return cmSystemTools::LowerCase(parameters.front());
+ }
+} lowerCaseNode;
+
+//----------------------------------------------------------------------------
+static const struct UpperCaseNode : public cmGeneratorExpressionNode
+{
+ UpperCaseNode() {}
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *,
+ const GeneratorExpressionContent *,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ return cmSystemTools::UpperCase(parameters.front());
+ }
+} upperCaseNode;
+
+//----------------------------------------------------------------------------
+static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode
+{
+ MakeCIdentifierNode() {}
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *,
+ const GeneratorExpressionContent *,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ return cmSystemTools::MakeCidentifier(parameters.front().c_str());
+ }
+} makeCIdentifierNode;
+
+//----------------------------------------------------------------------------
static const struct Angle_RNode : public cmGeneratorExpressionNode
{
Angle_RNode() {}
@@ -1442,6 +1484,12 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
return &targetSoNameFileDirNode;
else if (identifier == "STREQUAL")
return &strEqualNode;
+ else if (identifier == "LOWER_CASE")
+ return &lowerCaseNode;
+ else if (identifier == "UPPER_CASE")
+ return &upperCaseNode;
+ else if (identifier == "MAKE_C_IDENTIFIER")
+ return &makeCIdentifierNode;
else if (identifier == "BOOL")
return &boolNode;
else if (identifier == "ANGLE-R")
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index e0df8c2490..edadb87ee8 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -193,6 +193,9 @@ add_custom_target(check-part3 ALL
-Dtest_platform_id_Linux=$<PLATFORM_ID:Linux>
-Dtest_platform_id_Windows=$<PLATFORM_ID:Windows>
-Dtest_platform_id_Darwin=$<PLATFORM_ID:Darwin>
+ -Dlower_case=$<LOWER_CASE:MiXeD>
+ -Dupper_case=$<UPPER_CASE:MiXeD>
+ -Dmake_c_identifier=$<MAKE_C_IDENTIFIER:4foo:+bar-$>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake
COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)"
VERBATIM
diff --git a/Tests/GeneratorExpression/check-part3.cmake b/Tests/GeneratorExpression/check-part3.cmake
index 93ea48765a..a86db313ce 100644
--- a/Tests/GeneratorExpression/check-part3.cmake
+++ b/Tests/GeneratorExpression/check-part3.cmake
@@ -34,3 +34,6 @@ foreach(system Linux Windows Darwin)
check(test_platform_id_${system} 0)
endif()
endforeach()
+check(lower_case "mixed")
+check(upper_case "MIXED")
+check(make_c_identifier "_4foo__bar__")