mirror of https://github.com/qt/qtbase.git
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>
This commit is contained in:
parent
8fc3fcf425
commit
f5c69a5195
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue