mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-02 11:49:55 -06:00
install(PACKAGE_INFO): Fix error when usage requirements contain certain genex
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 `:`.
This commit is contained in:
@@ -191,16 +191,17 @@ static std::string extractAllGeneratorExpressions(
|
||||
colons.push(c);
|
||||
}
|
||||
} else if (c[0] == '>') {
|
||||
if (collected && !starts.empty() && !colons.empty()) {
|
||||
(*collected)[std::string(starts.top() + 2, colons.top())].push_back(
|
||||
std::string(colons.top() + 1, c));
|
||||
if (!colons.empty() && !starts.empty() &&
|
||||
starts.top() < colons.top()) {
|
||||
if (collected) {
|
||||
(*collected)[std::string(starts.top() + 2, colons.top())]
|
||||
.push_back(std::string(colons.top() + 1, c));
|
||||
}
|
||||
colons.pop();
|
||||
}
|
||||
if (!starts.empty()) {
|
||||
starts.pop();
|
||||
}
|
||||
if (!colons.empty()) {
|
||||
colons.pop();
|
||||
}
|
||||
if (starts.empty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ project(LinkInterfaceGeneratorExpression CXX)
|
||||
|
||||
add_library(foo foo.cxx)
|
||||
add_library(bar foo.cxx)
|
||||
target_link_libraries(bar $<1:foo>)
|
||||
target_link_libraries(bar $<1:foo> $<1:$<CONFIG>>)
|
||||
|
||||
install(TARGETS foo EXPORT foo)
|
||||
export(EXPORT foo PACKAGE_INFO foo)
|
||||
|
||||
@@ -35,3 +35,7 @@ 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"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user