diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-06-20 19:20:34 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-06-22 20:18:39 +0200 |
commit | 754512a64dffa20165e5b08b77e34b82c072f7f8 (patch) | |
tree | dab9e28c8b6e1367574af2cc8aa0a1cf60683129 /cmake/QtFinishPrlFile.cmake | |
parent | c3b959733a739e9b2fc00b2af469fa44f3048e29 (diff) |
CMake: Fix prl files not to contain hard-coded library paths
Make sure to convert absolute paths generated using the
$<TARGET_LINKER_FILE> generator expressions into relative paths.
Because prl files are generated for both modules and plugins, we need
to pass both a list of qt module locations and qt plugin locations
to QtFinishPrl.cmake, and then try to make the absolute path relative
to each passed directory.
A warning assertion is shown if we no relative path could be made,
which will cause an absolute path to be embedded. This should not
happen though.
Amends f4e998125981038e5e50dab8cc56039faaa0b750
Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104396
Change-Id: Id68395c0dbb20aad5c510d77835cc931b9396556
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'cmake/QtFinishPrlFile.cmake')
-rw-r--r-- | cmake/QtFinishPrlFile.cmake | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/cmake/QtFinishPrlFile.cmake b/cmake/QtFinishPrlFile.cmake index 78c7d15770..9c93bd49a1 100644 --- a/cmake/QtFinishPrlFile.cmake +++ b/cmake/QtFinishPrlFile.cmake @@ -89,7 +89,28 @@ foreach(line ${lines}) # qmake's UnixMakefileGenerator::findLibraries then takes care of deduplication, which # keeps the last occurrence of the library on the link line, the one after the object # files. - list(APPEND libs_to_prepend "${target_library_path}") + qt_internal_path_is_relative_to_qt_lib_path( + "${target_library_path}" "${QT_LIB_DIRS}" lib_is_a_qt_module relative_lib) + if(NOT lib_is_a_qt_module) + qt_internal_path_is_relative_to_qt_lib_path( + "${target_library_path}" "${QT_PLUGIN_DIRS}" lib_is_a_qt_plugin relative_lib) + endif() + if(NOT lib_is_a_qt_module AND NOT lib_is_a_qt_plugin) + message(AUTHOR_WARNING + "Could not determine relative path for library ${target_library_path} when " + "generating prl file contents. An absolute path will be embedded, which " + "will cause issues if the Qt installation is relocated.") + list(APPEND libs_to_prepend "${target_library_path}") + else() + set(qmake_lib_path_prefix "$$[QT_PRL_INVALID_QMAKE_VARIABLE]") + if(lib_is_a_qt_module) + set(qmake_lib_path_prefix "$$[QT_INSTALL_LIBS]") + elseif(lib_is_a_qt_plugin) + set(qmake_lib_path_prefix "$$[QT_INSTALL_PLUGINS]") + endif() + qt_strip_library_version_suffix(relative_lib "${relative_lib}") + list(APPEND libs_to_prepend "${qmake_lib_path_prefix}/${relative_lib}") + endif() list(PREPEND adjusted_libs ${libs_to_prepend}) endif() |