CMake: Fix qml plugin prl files not to have hardcoded paths

The previous fix 754512a64dffa20165e5b08b77e34b82c072f7f8
did not handle qml plugins, which meant that they would still have
hardcoded paths and see warnings like the one below when generating
the prl files

 CMake Warning (dev) at
 cmake/QtFinishPrlFile.cmake:103 (message):
  Could not determine relative path for library
  qml/QtQml/WorkerScript/libworkerscriptplugin_debug.a
  when generating prl file contents.  An absolute path will be
  embedded, which will cause issues if the Qt installation is
  relocated.

Handle qml plugins as well.

Amends 754512a64dffa20165e5b08b77e34b82c072f7f8
Amends f4e998125981038e5e50dab8cc56039faaa0b750

Fixes: QTBUG-104708
Task-number: QTBUG-104396
Change-Id: Icfb1069d1cb0a39a35004b20e58ee6e386d14f3b
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 9ea2f7f4b1192f3429aa2d3e278097008bc773bb)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2022-07-01 12:42:31 +02:00 committed by Qt Cherry-pick Bot
parent a83a943bff
commit 64a0cbe9ea
2 changed files with 13 additions and 0 deletions

View File

@ -96,6 +96,10 @@ foreach(line ${lines})
"${target_library_path}" "${QT_PLUGIN_DIRS}" lib_is_a_qt_plugin relative_lib) "${target_library_path}" "${QT_PLUGIN_DIRS}" lib_is_a_qt_plugin relative_lib)
endif() endif()
if(NOT lib_is_a_qt_module AND NOT lib_is_a_qt_plugin) if(NOT lib_is_a_qt_module AND NOT lib_is_a_qt_plugin)
qt_internal_path_is_relative_to_qt_lib_path(
"${target_library_path}" "${QT_QML_DIRS}" lib_is_a_qt_qml_plugin relative_lib)
endif()
if(NOT lib_is_a_qt_module AND NOT lib_is_a_qt_plugin AND NOT lib_is_a_qt_qml_plugin)
message(AUTHOR_WARNING message(AUTHOR_WARNING
"Could not determine relative path for library ${target_library_path} when " "Could not determine relative path for library ${target_library_path} when "
"generating prl file contents. An absolute path will be embedded, which " "generating prl file contents. An absolute path will be embedded, which "
@ -107,6 +111,8 @@ foreach(line ${lines})
set(qmake_lib_path_prefix "$$[QT_INSTALL_LIBS]") set(qmake_lib_path_prefix "$$[QT_INSTALL_LIBS]")
elseif(lib_is_a_qt_plugin) elseif(lib_is_a_qt_plugin)
set(qmake_lib_path_prefix "$$[QT_INSTALL_PLUGINS]") set(qmake_lib_path_prefix "$$[QT_INSTALL_PLUGINS]")
elseif(lib_is_a_qt_qml_plugin)
set(qmake_lib_path_prefix "$$[QT_INSTALL_QML]")
endif() endif()
qt_strip_library_version_suffix(relative_lib "${relative_lib}") qt_strip_library_version_suffix(relative_lib "${relative_lib}")
list(APPEND libs_to_prepend "${qmake_lib_path_prefix}/${relative_lib}") list(APPEND libs_to_prepend "${qmake_lib_path_prefix}/${relative_lib}")

View File

@ -145,6 +145,12 @@ ${prl_step1_content_libs}
"${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_PLUGINSDIR}") "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_PLUGINSDIR}")
endif() endif()
set(qt_qml_dirs "${QT_BUILD_DIR}/${INSTALL_QMLDIR}")
if(QT_WILL_INSTALL)
list(APPEND qt_qml_dirs
"${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}/${INSTALL_QMLDIR}")
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
@ -180,6 +186,7 @@ ${prl_step1_content_libs}
"-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}" "-DQT_PLUGIN_DIRS=${qt_plugin_dirs}"
"-DQT_QML_DIRS=${qt_qml_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