Genex: Add {UPPER,LOWER}_CASE and MAKE_C_IDENTIFIER.

This commit is contained in:
Stephen Kelly 2013-11-20 21:40:29 +01:00
parent 754b321272
commit 1242f4e569
4 changed files with 60 additions and 0 deletions

View File

@ -178,3 +178,9 @@ property is non-empty::
Content of ``...`` when the property is exported using :command:`export`, or 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 when the target is used by another target in the same buildsystem. Expands to
the empty string otherwise. 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.

View File

@ -198,6 +198,48 @@ static const struct StrEqualNode : public cmGeneratorExpressionNode
} }
} strEqualNode; } 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 static const struct Angle_RNode : public cmGeneratorExpressionNode
{ {
@ -1442,6 +1484,12 @@ cmGeneratorExpressionNode* GetNode(const std::string &identifier)
return &targetSoNameFileDirNode; return &targetSoNameFileDirNode;
else if (identifier == "STREQUAL") else if (identifier == "STREQUAL")
return &strEqualNode; 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") else if (identifier == "BOOL")
return &boolNode; return &boolNode;
else if (identifier == "ANGLE-R") else if (identifier == "ANGLE-R")

View File

@ -193,6 +193,9 @@ add_custom_target(check-part3 ALL
-Dtest_platform_id_Linux=$<PLATFORM_ID:Linux> -Dtest_platform_id_Linux=$<PLATFORM_ID:Linux>
-Dtest_platform_id_Windows=$<PLATFORM_ID:Windows> -Dtest_platform_id_Windows=$<PLATFORM_ID:Windows>
-Dtest_platform_id_Darwin=$<PLATFORM_ID:Darwin> -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 -P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake
COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)" COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 3)"
VERBATIM VERBATIM

View File

@ -34,3 +34,6 @@ foreach(system Linux Windows Darwin)
check(test_platform_id_${system} 0) check(test_platform_id_${system} 0)
endif() endif()
endforeach() endforeach()
check(lower_case "mixed")
check(upper_case "MIXED")
check(make_c_identifier "_4foo__bar__")