From f57bfa3ba0b3cc6a4f53eebebbe16c0e41ccee3a Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 25 Jun 2021 15:16:19 +0200 Subject: CMake: Pierce through LINK_ONLY deps in finalizer dep traversal Ensure that the finalizer approach of __qt_internal_propagate_object_library considers $ 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 $ 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 --- cmake/QtPublicTargetHelpers.cmake | 5 +++++ 1 file changed, 5 insertions(+) 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 "^\\$$") + set(lib "${CMAKE_MATCH_1}") + endif() if(TARGET ${lib}) get_target_property(aliased_target ${lib} ALIASED_TARGET) if(aliased_target) -- cgit v1.2.3