Merge topic 'genex-link-group-extra'

f217446772 Genex: Fix crash on strings concatenated on LINK_GROUP

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !12760
This commit is contained in:
Brad King authored and Kitware Robot committed 2026-11-03 09:22:03 -05:00
commit da2499b057
3 files changed
+21 -1

No files matched your search

+5 -1
View File
@@ -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)