From 1242f4e56924ddfb7f954d820918c89c333e1dc5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 20 Nov 2013 21:40:29 +0100 Subject: Genex: Add {UPPER,LOWER}_CASE and MAKE_C_IDENTIFIER. --- Help/manual/cmake-generator-expressions.7.rst | 6 ++++ Source/cmGeneratorExpressionEvaluator.cxx | 48 +++++++++++++++++++++++++++ Tests/GeneratorExpression/CMakeLists.txt | 3 ++ Tests/GeneratorExpression/check-part3.cmake | 3 ++ 4 files changed, 60 insertions(+) diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index bd9e7c2..ed28abd 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. +``$`` + Content of ``...`` converted to lower case. +``$`` + Content of ``...`` converted to upper case. +``$`` + Content of ``...`` converted to a C identifier. diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 17bf041..0f8c4e3 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 ¶meters, + cmGeneratorExpressionContext *, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *) const + { + return cmSystemTools::LowerCase(parameters.front()); + } +} lowerCaseNode; + +//---------------------------------------------------------------------------- +static const struct UpperCaseNode : public cmGeneratorExpressionNode +{ + UpperCaseNode() {} + + std::string Evaluate(const std::vector ¶meters, + cmGeneratorExpressionContext *, + const GeneratorExpressionContent *, + cmGeneratorExpressionDAGChecker *) const + { + return cmSystemTools::UpperCase(parameters.front()); + } +} upperCaseNode; + +//---------------------------------------------------------------------------- +static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode +{ + MakeCIdentifierNode() {} + + std::string Evaluate(const std::vector ¶meters, + 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 e0df8c2..edadb87 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=$ -Dtest_platform_id_Windows=$ -Dtest_platform_id_Darwin=$ + -Dlower_case=$ + -Dupper_case=$ + -Dmake_c_identifier=$ -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 93ea487..a86db31 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__") -- cgit v0.12