mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 05:11:15 -06:00
Since commit 13c7bb5b0c (cmGeneratorExpression: Update strip function to
collect parsed expressions, 2025-04-08, v4.1.0-rc1~361^2~1), the logic
to strip generator expressions would error if the stripped expressions
were being collected and an expression without a `:` was found inside an
expression with a `:`. This resulted in an error when exporting a target
that contained such a generator expression in its link libraries or
compile definitions.
Address the error by checking whether the latest `$<` proceeded the
latest `:`.
42 lines
881 B
CMake
42 lines
881 B
CMake
function(test_strip input expected)
|
|
string(GENEX_STRIP "${input}" strip)
|
|
if (NOT strip STREQUAL expected)
|
|
message(FATAL_ERROR "message(GENEXP_STRIP \"${input}\")
|
|
evaluated to \"${strip}\"
|
|
expected \"${expected}\"")
|
|
endif()
|
|
endfunction()
|
|
|
|
test_strip( # Simple case
|
|
"$<BOOL:1>"
|
|
""
|
|
)
|
|
test_strip( # LHS contains generator expression
|
|
"$<$<CONFIG:Release>:NDEBUG>;DEBUG"
|
|
"DEBUG"
|
|
)
|
|
test_strip( # RHS contains generator expression
|
|
"$<AND:1,$<BOOL:TRUE>>"
|
|
""
|
|
)
|
|
test_strip( # Empty and unfinished expressions
|
|
"$<>$<$<>"
|
|
"$<$<>"
|
|
)
|
|
test_strip( # Multiple independent expressions
|
|
"$<IF:TRUE,TRUE,FALSE> / $<IF:TRUE,TRUE,FALSE>"
|
|
" / "
|
|
)
|
|
test_strip( # Multiple : in one expression
|
|
"$<1:2:3>"
|
|
""
|
|
)
|
|
test_strip( # Multiple case
|
|
"1$<AND:1,0>2$<IF:$<$<BOOL:1>:$<CONFIG:RELEASE>>,TRUE,FALSE>3"
|
|
"123"
|
|
)
|
|
test_strip( # No : inside of :
|
|
"$<1:$<SEMICOLON>>1"
|
|
"1"
|
|
)
|