CMake: Fix rpath-link dependencies when cross-compiling
Private Qt module dependencies of a Qt module are recorded in the IMPORTED_LINK_DEPENDENT_LIBRARIES property of a Qt module. This property is used to compute the runtime dependency dir path to be passed to the linker via the -rpath-link option. If the referenced target does not exist in the scope where it's used, no -rpath-link will be generated (or at least that specific dir path won't be passed). The linking operation will either fail saying the library is not found, or a different version of the library might be silently picked up in the sysroot or other implicit lib dir. Make sure that QtFooModuleDependencies.cmake calls find_package() for all Qt module private dependencies (or other Qt provided 3rd party libs in the Qt6:: namespace) so that the targets are in scope and IMPORTED_LINK_DEPENDENT_LIBRARIES does its job. qmake also records the INTERFACE_LINK_LIBRARIES of a private Qt module as the runtime dependencies of the module. It's not clear why it does that. A private Qt module is an INTERFACE_LIBRARY so it shouldn't add any new runtime dependencies. Nevertheless, the find_package part of that has been recently addressed in 2b6500cd15c0a41cf3e5eea8178e2044012dbd97 for a different reason. This change is basically the CMake equivalent of 326b91ea788b013512ae911c51cc19497d88916d Pick-to: 6.2 Fixes: QTBUG-86533 Change-Id: Iaf514a14acaded4e8752149cca0c159a271be188 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
9153458731
commit
87215c70c0
@ -308,10 +308,18 @@ function(qt_register_target_dependencies target public_libs private_libs)
|
||||
set(target_deps "")
|
||||
endif()
|
||||
|
||||
# Only process private dependencies if target is a static library
|
||||
get_target_property(target_type ${target} TYPE)
|
||||
set(lib_list ${public_libs})
|
||||
if (target_type STREQUAL "STATIC_LIBRARY")
|
||||
# Record Qt target private dependencies information which will be used to generate
|
||||
# find_dependency() calls.
|
||||
#
|
||||
# Private static library dependencies become $<LINK_ONLY:> dependencies in
|
||||
# INTERFACE_LINK_LIBRARIES.
|
||||
#
|
||||
# Private shared library dependencies are listed in the target's
|
||||
# IMPORTED_LINK_DEPENDENT_LIBRARIES and used in rpath-link calculation.
|
||||
# See QTBUG-86533 for some details.
|
||||
if (target_type STREQUAL "STATIC_LIBRARY" OR target_type STREQUAL "SHARED_LIBRARY")
|
||||
list(APPEND lib_list ${private_libs})
|
||||
endif()
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user