summaryrefslogtreecommitdiffstats
path: root/cmake/QtFinishPrlFile.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-06-20 19:20:34 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-06-25 15:27:23 +0000
commitdd26c4234bdd41b18dedd60b88b49e18a94d80d7 (patch)
tree6416d09bea9e3f331611c21384d427f7297f854c /cmake/QtFinishPrlFile.cmake
parentacaed119e082a5960c53e50a04064e4fb652040f (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 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> (cherry picked from commit 754512a64dffa20165e5b08b77e34b82c072f7f8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake/QtFinishPrlFile.cmake')
-rw-r--r--cmake/QtFinishPrlFile.cmake23
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()