GenEx: Parse comma after colon tokens specially
Otherwise the comma is treated as plain text by ParseContent. $<STREQUAL:,> should be valid and true. $<STREQUAL:,something> should be valid and false. $<STREQUAL:,,> should be non-valid as it is 3 parameters. $<STREQUAL:something,,> should be non-valid as it is 3 parameters. Additionally, this allows reporting the correct error for other expressions. For example $<TARGET_PROPERTY:,> should be invalid because it has an empty target and empty property. It shouldn't attempt to read the property ',' on the 'implicit this' target.
This commit is contained in:
parent
a4985a9af9
commit
b3d8f5dab7
|
@ -118,10 +118,16 @@ void cmGeneratorExpressionParser::ParseGeneratorExpression(
|
||||||
colonToken = this->it;
|
colonToken = this->it;
|
||||||
parameters.resize(parameters.size() + 1);
|
parameters.resize(parameters.size() + 1);
|
||||||
++this->it;
|
++this->it;
|
||||||
|
while (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator)
|
||||||
|
{
|
||||||
|
commaTokens.push_back(this->it);
|
||||||
|
parameters.resize(parameters.size() + 1);
|
||||||
|
++this->it;
|
||||||
|
}
|
||||||
while(this->it->TokenType != cmGeneratorExpressionToken::EndExpression)
|
while(this->it->TokenType != cmGeneratorExpressionToken::EndExpression)
|
||||||
{
|
{
|
||||||
this->ParseContent(*(parameters.end() - 1));
|
this->ParseContent(*(parameters.end() - 1));
|
||||||
if (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator)
|
while (this->it->TokenType == cmGeneratorExpressionToken::CommaSeparator)
|
||||||
{
|
{
|
||||||
commaTokens.push_back(this->it);
|
commaTokens.push_back(this->it);
|
||||||
parameters.resize(parameters.size() + 1);
|
parameters.resize(parameters.size() + 1);
|
||||||
|
|
|
@ -37,6 +37,8 @@ add_custom_target(check ALL
|
||||||
-Dtest_strequal_angle_r=$<STREQUAL:$<ANGLE-R>,$<ANGLE-R>>
|
-Dtest_strequal_angle_r=$<STREQUAL:$<ANGLE-R>,$<ANGLE-R>>
|
||||||
-Dtest_strequal_comma=$<STREQUAL:$<COMMA>,$<COMMA>>
|
-Dtest_strequal_comma=$<STREQUAL:$<COMMA>,$<COMMA>>
|
||||||
-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_one_empty=$<STREQUAL:something,>
|
||||||
-Dtest_angle_r=$<ANGLE-R>
|
-Dtest_angle_r=$<ANGLE-R>
|
||||||
-Dtest_comma=$<COMMA>
|
-Dtest_comma=$<COMMA>
|
||||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake
|
-P ${CMAKE_CURRENT_SOURCE_DIR}/check.cmake
|
||||||
|
|
|
@ -38,5 +38,7 @@ check(test_strequal_no_yes "0")
|
||||||
check(test_strequal_angle_r "1")
|
check(test_strequal_angle_r "1")
|
||||||
check(test_strequal_comma "1")
|
check(test_strequal_comma "1")
|
||||||
check(test_strequal_angle_r_comma "0")
|
check(test_strequal_angle_r_comma "0")
|
||||||
|
check(test_strequal_both_empty "1")
|
||||||
|
check(test_strequal_one_empty "0")
|
||||||
check(test_angle_r ">")
|
check(test_angle_r ">")
|
||||||
check(test_comma ",")
|
check(test_comma ",")
|
||||||
|
|
|
@ -20,7 +20,7 @@ CMake Error at BadNOT.cmake:1 \(add_custom_target\):
|
||||||
|
|
||||||
\$<NOT:,>
|
\$<NOT:,>
|
||||||
|
|
||||||
\$<NOT> parameter must resolve to exactly one '0' or '1' value.
|
\$<NOT> expression requires exactly one parameter.
|
||||||
Call Stack \(most recent call first\):
|
Call Stack \(most recent call first\):
|
||||||
CMakeLists.txt:3 \(include\)
|
CMakeLists.txt:3 \(include\)
|
||||||
+
|
+
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
1
|
|
@ -0,0 +1,38 @@
|
||||||
|
CMake Error at BadStrEqual.cmake:1 \(add_custom_target\):
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<STREQUAL>
|
||||||
|
|
||||||
|
\$<STREQUAL> expression requires 2 comma separated parameters, but got 0
|
||||||
|
instead.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
||||||
|
+CMake Error at BadStrEqual.cmake:1 \(add_custom_target\):
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<STREQUAL:>
|
||||||
|
|
||||||
|
\$<STREQUAL> expression requires 2 comma separated parameters, but got 1
|
||||||
|
instead.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
||||||
|
+
|
||||||
|
CMake Error at BadStrEqual.cmake:1 \(add_custom_target\):
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<STREQUAL:,,>
|
||||||
|
|
||||||
|
\$<STREQUAL> expression requires 2 comma separated parameters, but got 3
|
||||||
|
instead.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
||||||
|
+
|
||||||
|
CMake Error at BadStrEqual.cmake:1 \(add_custom_target\):
|
||||||
|
Error evaluating generator expression:
|
||||||
|
|
||||||
|
\$<STREQUAL:something,,>
|
||||||
|
|
||||||
|
\$<STREQUAL> expression requires 2 comma separated parameters, but got 3
|
||||||
|
instead.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)$
|
|
@ -0,0 +1,6 @@
|
||||||
|
add_custom_target(check ALL COMMAND check
|
||||||
|
$<STREQUAL>
|
||||||
|
$<STREQUAL:>
|
||||||
|
$<STREQUAL:,,>
|
||||||
|
$<STREQUAL:something,,>
|
||||||
|
VERBATIM)
|
|
@ -4,3 +4,4 @@ run_cmake(BadCONFIG)
|
||||||
run_cmake(BadOR)
|
run_cmake(BadOR)
|
||||||
run_cmake(BadAND)
|
run_cmake(BadAND)
|
||||||
run_cmake(BadNOT)
|
run_cmake(BadNOT)
|
||||||
|
run_cmake(BadStrEqual)
|
||||||
|
|
Loading…
Reference in New Issue