mirror of
https://github.com/Kitware/CMake.git
synced 2026-11-06 05:16:58 +00:00
Genex: Fix crash on strings concatenated on LINK_GROUP
When a string is concatenated to the beginning and/or end of a `$<LINK_GROUP:...>` generator expression without a semicolon, the internal group marker is disrupted, leading to a crash after evaluation.
This commit is contained in:
1 parent
4e0fa8da34
commit
f217446772
3 files changed
+21
-1
No files matched your search
@@ -1076,7 +1076,11 @@ void cmComputeLinkDepends::AddLinkEntries(cm::optional<size_t> depender_index,
|
||||
size_t dependee_index;
|
||||
|
||||
if (cmHasPrefix(item.AsStr(), LG_END) && cmHasSuffix(item.AsStr(), '>')) {
|
||||
assert(group);
|
||||
if (!group) {
|
||||
// The matching group start was not recognized, e.g., because
|
||||
// other text was concatenated to it. Ignore the stray end.
|
||||
continue;
|
||||
}
|
||||
dependee_index = group->first;
|
||||
if (group->second) {
|
||||
this->GroupItems.emplace(group->first, std::move(groupItems));
|
||||
|
||||
@@ -29,6 +29,7 @@ run_cmake(nested-incompatible-features2)
|
||||
run_cmake(circular-dependencies1)
|
||||
run_cmake(circular-dependencies2)
|
||||
run_cmake(only-targets)
|
||||
run_cmake(concatenated-group-begin)
|
||||
|
||||
# usage of LINK_LIBRARY with LINK_GROUP
|
||||
run_cmake(incompatible-library-features1)
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
enable_language(C)
|
||||
|
||||
set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE)
|
||||
set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--stop")
|
||||
|
||||
add_library(dep SHARED empty.c)
|
||||
|
||||
# Text concatenated before the genex hides the start of the group.
|
||||
add_library(lib1 SHARED empty.c)
|
||||
target_link_libraries(lib1 PRIVATE "x$<LINK_GROUP:feat,dep>")
|
||||
|
||||
add_library(iface INTERFACE)
|
||||
target_link_libraries(iface INTERFACE "x$<LINK_GROUP:feat,dep>")
|
||||
add_library(lib2 SHARED empty.c)
|
||||
target_link_libraries(lib2 PRIVATE iface)
|
||||
Reference in new issue
Block a user