summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-10-18 17:08:27 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-10-20 15:14:58 +0000
commit90ae6ee201830b5d927bb139f347c33be33cf600 (patch)
tree4397bd9cbb08efffa2f27f48deae49f1dfafef8d /cmake
parent278bd3286790ec4f6c59858245b0a74fbf028946 (diff)
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 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> (cherry picked from commit 87215c70c0ff0bdc52dfa463f050d2aa049cdd91) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtFindPackageHelpers.cmake12
1 files changed, 10 insertions, 2 deletions
diff --git a/cmake/QtFindPackageHelpers.cmake b/cmake/QtFindPackageHelpers.cmake
index 8519922f85..7d8e9420e2 100644
--- a/cmake/QtFindPackageHelpers.cmake
+++ b/cmake/QtFindPackageHelpers.cmake
@@ -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()