summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@qt.io>2021-05-04 17:09:47 +1000
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-05-11 18:57:17 +0200
commitf5c69a5195684bf11a4d55c189435eea35e66125 (patch)
tree8bc081946d38a9705d46525b0bc47baa1e666087 /src
parent8fc3fcf4252ccc9a8db22f468ca7a1fcbb0c845b (diff)
CMake: Walk link dependencies recursively to work out finalizers
When versionless targets are used, they are defined as INTERFACE IMPORTED targets. These will sit between the executable target created by qt6_add_executable() and the underlying Qt6::XXX module library where the finalizers are defined. We need to recurse through the link dependencies to ensure we pick up these finalizers. This will also ensure we pick up finalizers in deeper targets from transitive dependencies. Fixes: QTBUG-93387 Change-Id: If8524ebf0e75c8790858dd7e42aa1cf4ebdfd989 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/Qt6CoreMacros.cmake16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 6d477180a0..6ebcf279ba 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -517,7 +517,9 @@ function(qt6_finalize_executable target)
# We can't evaluate generator expressions at configure time, so we can't
# ask for any transitive properties or even the full library dependency
- # chain. We can still look at the immediate dependencies though and query
+ # chain.
+ # We can still look at the immediate dependencies
+ # (and recursively their dependencies) and query
# any that are not expressed as generator expressions. For any we can
# identify as a CMake target known to the current scope, we can check if
# that target has a finalizer to be called. This is expected to cover the
@@ -526,12 +528,11 @@ function(qt6_finalize_executable target)
# responsible for calling any relevant functions themselves instead of
# relying on these automatic finalization calls.
set(finalizers)
- get_target_property(immediate_deps ${target} LINK_LIBRARIES)
- if(immediate_deps)
- foreach(dep IN LISTS immediate_deps)
- if(NOT TARGET ${dep})
- continue()
- endif()
+
+ __qt_internal_collect_all_target_dependencies("${target}" dep_targets)
+
+ if(dep_targets)
+ foreach(dep IN LISTS dep_targets)
get_target_property(dep_finalizers ${dep}
INTERFACE_QT_EXECUTABLE_FINALIZERS
)
@@ -541,6 +542,7 @@ function(qt6_finalize_executable target)
endforeach()
list(REMOVE_DUPLICATES finalizers)
endif()
+
if(finalizers)
if(CMAKE_VERSION VERSION_LESS 3.18)
# cmake_language() not available