diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-12-31 14:57:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-01-07 14:38:01 (GMT) |
commit | 3917d86b261f0b88eb5cf0e8d2700c70cebdbe4b (patch) | |
tree | b870364a3fec0acba6eb8c320f665ed181281535 | |
parent | 5169130539110ff479875e76784109f174c28c69 (diff) | |
download | CMake-3917d86b261f0b88eb5cf0e8d2700c70cebdbe4b.zip CMake-3917d86b261f0b88eb5cf0e8d2700c70cebdbe4b.tar.gz CMake-3917d86b261f0b88eb5cf0e8d2700c70cebdbe4b.tar.bz2 |
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.
-rw-r--r-- | Help/manual/cmake-generator-expressions.7.rst | 2 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionEvaluator.cxx | 8 | ||||
-rw-r--r-- | Tests/GeneratorExpression/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/GeneratorExpression/check-part1.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt | 11 | ||||
-rw-r--r-- | Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake | 1 |
6 files changed, 11 insertions, 13 deletions
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 12cfaf8..ac8c3f8 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -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 diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx index 259ba94..5edea86 100644 --- a/Source/cmGeneratorExpressionEvaluator.cxx +++ b/Source/cmGeneratorExpressionEvaluator.cxx @@ -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."); diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt index 9512efc..3b85dc3 100644 --- a/Tests/GeneratorExpression/CMakeLists.txt +++ b/Tests/GeneratorExpression/CMakeLists.txt @@ -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> diff --git a/Tests/GeneratorExpression/check-part1.cmake b/Tests/GeneratorExpression/check-part1.cmake index 9bef159..3207582 100644 --- a/Tests/GeneratorExpression/check-part1.cmake +++ b/Tests/GeneratorExpression/check-part1.cmake @@ -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") diff --git a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt index 1cfbf40..964ea4d 100644 --- a/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt +++ b/Tests/RunCMake/GeneratorExpression/BadCONFIG-stderr.txt @@ -1,15 +1,6 @@ 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: - \$<CONFIG:.> Expression syntax not recognized. @@ -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\) + diff --git a/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake b/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake index c27ea5f..5c22aaa 100644 --- a/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake +++ b/Tests/RunCMake/GeneratorExpression/BadCONFIG.cmake @@ -1,5 +1,4 @@ add_custom_target(check ALL COMMAND check - $<CONFIG> $<CONFIG:.> $<CONFIG:Foo,Bar> $<CONFIG:Foo-Bar> |