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 f4e9981259
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>
This commit is contained in:
parent
c3b959733a
commit
754512a64d
@ -89,7 +89,28 @@ foreach(line ${lines})
|
|||||||
# qmake's UnixMakefileGenerator::findLibraries then takes care of deduplication, which
|
# 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
|
# keeps the last occurrence of the library on the link line, the one after the object
|
||||||
# files.
|
# 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})
|
list(PREPEND adjusted_libs ${libs_to_prepend})
|
||||||
endif()
|
endif()
|
||||||
|
@ -139,6 +139,12 @@ ${prl_step1_content_libs}
|
|||||||
"${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_LIBDIR}")
|
"${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_LIBDIR}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(qt_plugin_dirs "${QT_BUILD_DIR}/${INSTALL_PLUGINSDIR}")
|
||||||
|
if(QT_WILL_INSTALL)
|
||||||
|
list(APPEND qt_plugin_dirs
|
||||||
|
"${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_PLUGINSDIR}")
|
||||||
|
endif()
|
||||||
|
|
||||||
foreach(config ${configs})
|
foreach(config ${configs})
|
||||||
# Output file for dependency tracking, and which will contain the final content.
|
# Output file for dependency tracking, and which will contain the final content.
|
||||||
qt_path_join(prl_step2_path
|
qt_path_join(prl_step2_path
|
||||||
@ -173,6 +179,7 @@ ${prl_step1_content_libs}
|
|||||||
"-DLIBRARY_SUFFIXES=${library_suffixes}"
|
"-DLIBRARY_SUFFIXES=${library_suffixes}"
|
||||||
"-DLINK_LIBRARY_FLAG=${link_library_flag}"
|
"-DLINK_LIBRARY_FLAG=${link_library_flag}"
|
||||||
"-DQT_LIB_DIRS=${qt_lib_dirs}"
|
"-DQT_LIB_DIRS=${qt_lib_dirs}"
|
||||||
|
"-DQT_PLUGIN_DIRS=${qt_plugin_dirs}"
|
||||||
"-DIMPLICIT_LINK_DIRECTORIES=${implicit_link_directories}"
|
"-DIMPLICIT_LINK_DIRECTORIES=${implicit_link_directories}"
|
||||||
-P "${QT_CMAKE_DIR}/QtFinishPrlFile.cmake"
|
-P "${QT_CMAKE_DIR}/QtFinishPrlFile.cmake"
|
||||||
VERBATIM
|
VERBATIM
|
||||||
|
Loading…
Reference in New Issue
Block a user