diff options
authorAlexandru Croitor <>2021-06-25 15:16:19 +0200
committerQt Cherry-pick Bot <>2021-06-29 17:43:14 +0000
commitf57bfa3ba0b3cc6a4f53eebebbe16c0e41ccee3a (patch)
parent599d298c06b30661f3b90c9c6e4840ea3d271a60 (diff)
CMake: Pierce through LINK_ONLY deps in finalizer dep traversalv6.2.0-beta1
Ensure that the finalizer approach of __qt_internal_propagate_object_library considers $<LINK_ONLY:> libraries when traversing the dependencies of a target. The issue was discovered when using the Quick.Shapes QML module in a static build. The module has both a backing library and a plugin. The backing library has some resource objects associated with it. When the targets are exported, the plugin INTERFACE_LINK_LIBRARIES has a $<LINK_ONLY:QuickShapes> dependency. This ensures that the library will be linked, but depending on which linking approach in __qt_internal_propagate_object_library is used, the resources might not be linked to the final executable. The resources are linked correctly when using the target_link_libraries approach, but not when using the finalizer or target_sources approach. This change fixes the finalizer approach, but the target_sources approach is still broken. Amends a1fd4f51ada82854f35654158a334454e760a9f7 Change-Id: Ifbb91a17d388c3dc4263e17ec0d3bd5627b57cb4 Reviewed-by: Alexey Edelev <> Reviewed-by: Alexandru Croitor <> (cherry picked from commit 82063d9af1f9ad6cddab4d5526316816cbe1a77c) Reviewed-by: Qt Cherry-pick Bot <>
1 files changed, 5 insertions, 0 deletions
diff --git a/cmake/QtPublicTargetHelpers.cmake b/cmake/QtPublicTargetHelpers.cmake
index 5f09e97e0f..a116d2dd5d 100644
--- a/cmake/QtPublicTargetHelpers.cmake
+++ b/cmake/QtPublicTargetHelpers.cmake
@@ -177,6 +177,11 @@ function(__qt_internal_collect_object_libraries_recursively out_var target initi
set(object_libraries "")
foreach(lib IN LISTS libs interface_libs)
+ # Extract possible target from exported LINK_ONLY dependencies.
+ # This is super important for traversing backing library dependencies of qml plugins.
+ if(lib MATCHES "^\\$<LINK_ONLY:(.*)>$")
+ set(lib "${CMAKE_MATCH_1}")
+ endif()
if(TARGET ${lib})
get_target_property(aliased_target ${lib} ALIASED_TARGET)