Genex: Add a nullary form for CONFIG
This is consistent with other similar expressions such as PLATFORM_ID, and makes the CONFIGURATION expression obsolete. Fix an off-by-one error in GeneratorExpressionContent::EvaluateParameters exposed by a unit test. Remove the test for 'bad' nullary use of $<CONFIG>. Add a unit test to verify that $<CONFIG> and $<CONFIGURATION> have the same value.
This commit is contained in:
parent
5169130539
commit
3917d86b26
|
@ -104,6 +104,8 @@ expands to ``OLD_COMPILER`` if the
|
|||
than 4.2.0.
|
||||
|
||||
``$<CONFIGURATION>``
|
||||
Configuration name. Deprecated. Use ``CONFIG`` instead.
|
||||
``$<CONFIG>``
|
||||
Configuration name
|
||||
``$<PLATFORM_ID>``
|
||||
The CMake-id of the platform
|
||||
|
|
|
@ -676,13 +676,17 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
|
|||
{
|
||||
ConfigurationTestNode() {}
|
||||
|
||||
virtual int NumExpectedParameters() const { return 1; }
|
||||
virtual int NumExpectedParameters() const { return OneOrZeroParameters; }
|
||||
|
||||
std::string Evaluate(const std::vector<std::string> ¶meters,
|
||||
cmGeneratorExpressionContext *context,
|
||||
const GeneratorExpressionContent *content,
|
||||
cmGeneratorExpressionDAGChecker *) const
|
||||
{
|
||||
if (parameters.empty())
|
||||
{
|
||||
return configurationNode.Evaluate(parameters, context, content, 0);
|
||||
}
|
||||
cmsys::RegularExpression configValidator;
|
||||
configValidator.compile("^[A-Za-z0-9_]*$");
|
||||
if (!configValidator.find(parameters.begin()->c_str()))
|
||||
|
@ -1801,7 +1805,7 @@ std::string GeneratorExpressionContent::EvaluateParameters(
|
|||
+ "> expression requires at least one parameter.");
|
||||
}
|
||||
if (numExpected == cmGeneratorExpressionNode::OneOrZeroParameters
|
||||
&& parameters.size() > 2)
|
||||
&& parameters.size() > 1)
|
||||
{
|
||||
reportError(context, this->GetOriginalExpression(), "$<" + identifier
|
||||
+ "> expression requires one or zero parameters.");
|
||||
|
|
|
@ -13,6 +13,7 @@ add_custom_target(check-part1 ALL
|
|||
-Dtest_1=$<1:content>
|
||||
-Dtest_1_with_comma=$<1:-Wl,--no-undefined>
|
||||
-Dconfig=$<CONFIGURATION>
|
||||
-Dshort_config=$<CONFIG>
|
||||
-Dtest_and_0=$<AND:0>
|
||||
-Dtest_and_0_0=$<AND:0,0>
|
||||
-Dtest_and_0_1=$<AND:0,1>
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
include(${CMAKE_CURRENT_LIST_DIR}/check-common.cmake)
|
||||
|
||||
message(STATUS "config=[${config}]")
|
||||
check(config "${short_config}")
|
||||
check(test_0 "")
|
||||
check(test_0_with_comma "")
|
||||
check(test_1 "content")
|
||||
|
|
|
@ -1,12 +1,3 @@
|
|||
CMake Error at BadCONFIG.cmake:1 \(add_custom_target\):
|
||||
Error evaluating generator expression:
|
||||
|
||||
\$<CONFIG>
|
||||
|
||||
\$<CONFIG> expression requires exactly one parameter.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
+
|
||||
CMake Error at BadCONFIG.cmake:1 \(add_custom_target\):
|
||||
Error evaluating generator expression:
|
||||
|
||||
|
@ -21,7 +12,7 @@ CMake Error at BadCONFIG.cmake:1 \(add_custom_target\):
|
|||
|
||||
\$<CONFIG:Foo,Bar>
|
||||
|
||||
\$<CONFIG> expression requires exactly one parameter.
|
||||
\$<CONFIG> expression requires one or zero parameters.
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
+
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
add_custom_target(check ALL COMMAND check
|
||||
$<CONFIG>
|
||||
$<CONFIG:.>
|
||||
$<CONFIG:Foo,Bar>
|
||||
$<CONFIG:Foo-Bar>
|
||||
|
|
Loading…
Reference in New Issue