mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-11 03:50:43 -05:00
@@ -57,6 +57,8 @@ Available logical expressions are:
|
|||||||
``1`` if ``a`` is STREQUAL ``b``, else ``0``
|
``1`` if ``a`` is STREQUAL ``b``, else ``0``
|
||||||
``$<EQUAL:a,b>``
|
``$<EQUAL:a,b>``
|
||||||
``1`` if ``a`` is EQUAL ``b`` in a numeric comparison, else ``0``
|
``1`` if ``a`` is EQUAL ``b`` in a numeric comparison, else ``0``
|
||||||
|
``$<IN_LIST:a,b>``
|
||||||
|
``1`` if ``a`` is IN_LIST ``b``, else ``0``
|
||||||
``$<CONFIG:cfg>``
|
``$<CONFIG:cfg>``
|
||||||
``1`` if config is ``cfg``, else ``0``. This is a case-insensitive comparison.
|
``1`` if config is ``cfg``, else ``0``. This is a case-insensitive comparison.
|
||||||
The mapping in :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` is also considered by
|
The mapping in :prop_tgt:`MAP_IMPORTED_CONFIG_<CONFIG>` is also considered by
|
||||||
|
|||||||
5
Help/release/dev/genex-IN_LIST-logical-operator.rst
Normal file
5
Help/release/dev/genex-IN_LIST-logical-operator.rst
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
genex-IN_LIST-logical-operator
|
||||||
|
------------------------------
|
||||||
|
|
||||||
|
* A new ``$<IN_LIST:...>`` :manual:`generator expression <cmake-generator-expressions(7)>`
|
||||||
|
has been added.
|
||||||
@@ -275,6 +275,31 @@ static const struct EqualNode : public cmGeneratorExpressionNode
|
|||||||
}
|
}
|
||||||
} equalNode;
|
} equalNode;
|
||||||
|
|
||||||
|
static const struct InListNode : public cmGeneratorExpressionNode
|
||||||
|
{
|
||||||
|
InListNode() {}
|
||||||
|
|
||||||
|
int NumExpectedParameters() const override { return 2; }
|
||||||
|
|
||||||
|
std::string Evaluate(
|
||||||
|
const std::vector<std::string>& parameters,
|
||||||
|
cmGeneratorExpressionContext* /*context*/,
|
||||||
|
const GeneratorExpressionContent* /*content*/,
|
||||||
|
cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
|
||||||
|
{
|
||||||
|
std::vector<std::string> values;
|
||||||
|
cmSystemTools::ExpandListArgument(parameters[1], values);
|
||||||
|
if (values.empty()) {
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::find(values.cbegin(), values.cend(), parameters.front()) ==
|
||||||
|
values.cend()
|
||||||
|
? "0"
|
||||||
|
: "1";
|
||||||
|
}
|
||||||
|
} inListNode;
|
||||||
|
|
||||||
static const struct LowerCaseNode : public cmGeneratorExpressionNode
|
static const struct LowerCaseNode : public cmGeneratorExpressionNode
|
||||||
{
|
{
|
||||||
LowerCaseNode() {}
|
LowerCaseNode() {}
|
||||||
@@ -1827,6 +1852,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode(
|
|||||||
nodeMap["TARGET_BUNDLE_CONTENT_DIR"] = &targetBundleContentDirNode;
|
nodeMap["TARGET_BUNDLE_CONTENT_DIR"] = &targetBundleContentDirNode;
|
||||||
nodeMap["STREQUAL"] = &strEqualNode;
|
nodeMap["STREQUAL"] = &strEqualNode;
|
||||||
nodeMap["EQUAL"] = &equalNode;
|
nodeMap["EQUAL"] = &equalNode;
|
||||||
|
nodeMap["IN_LIST"] = &inListNode;
|
||||||
nodeMap["LOWER_CASE"] = &lowerCaseNode;
|
nodeMap["LOWER_CASE"] = &lowerCaseNode;
|
||||||
nodeMap["UPPER_CASE"] = &upperCaseNode;
|
nodeMap["UPPER_CASE"] = &upperCaseNode;
|
||||||
nodeMap["MAKE_C_IDENTIFIER"] = &makeCIdentifierNode;
|
nodeMap["MAKE_C_IDENTIFIER"] = &makeCIdentifierNode;
|
||||||
|
|||||||
@@ -57,6 +57,11 @@ add_custom_target(check-part1 ALL
|
|||||||
-Dtest_strequal_angle_r_comma=$<STREQUAL:$<ANGLE-R>,$<COMMA>>
|
-Dtest_strequal_angle_r_comma=$<STREQUAL:$<ANGLE-R>,$<COMMA>>
|
||||||
-Dtest_strequal_both_empty=$<STREQUAL:,>
|
-Dtest_strequal_both_empty=$<STREQUAL:,>
|
||||||
-Dtest_strequal_one_empty=$<STREQUAL:something,>
|
-Dtest_strequal_one_empty=$<STREQUAL:something,>
|
||||||
|
-Dtest_inlist_true=$<IN_LIST:a,a$<SEMICOLON>b>
|
||||||
|
-Dtest_inlist_false=$<IN_LIST:c,a$<SEMICOLON>b>
|
||||||
|
-Dtest_inlist_empty_1=$<IN_LIST:a,>
|
||||||
|
-Dtest_inlist_empty_2=$<IN_LIST:,a>
|
||||||
|
-Dtest_inlist_empty_3=$<IN_LIST:,>
|
||||||
-Dtest_angle_r=$<ANGLE-R>
|
-Dtest_angle_r=$<ANGLE-R>
|
||||||
-Dtest_comma=$<COMMA>
|
-Dtest_comma=$<COMMA>
|
||||||
-Dtest_semicolon=$<SEMICOLON>
|
-Dtest_semicolon=$<SEMICOLON>
|
||||||
|
|||||||
@@ -49,6 +49,11 @@ check(test_strequal_semicolon "1")
|
|||||||
check(test_strequal_angle_r_comma "0")
|
check(test_strequal_angle_r_comma "0")
|
||||||
check(test_strequal_both_empty "1")
|
check(test_strequal_both_empty "1")
|
||||||
check(test_strequal_one_empty "0")
|
check(test_strequal_one_empty "0")
|
||||||
|
check(test_inlist_true "1")
|
||||||
|
check(test_inlist_false "0")
|
||||||
|
check(test_inlist_empty_1 "0")
|
||||||
|
check(test_inlist_empty_2 "0")
|
||||||
|
check(test_inlist_empty_3 "0")
|
||||||
check(test_angle_r ">")
|
check(test_angle_r ">")
|
||||||
check(test_comma ",")
|
check(test_comma ",")
|
||||||
check(test_semicolon ";")
|
check(test_semicolon ";")
|
||||||
|
|||||||
Reference in New Issue
Block a user