CMake: Fix DESTDIR handling for plugin rpath adjustment on Linux

_qt_internal_set_rpath was using CMAKE_INSTALL_PREFIX instead of
QT_DEPLOY_PREFIX for the destination path, which ends up trying to
adjust the rpath of plugins in the regular install destination, rather
than in DESTDIR.

Change the code to use QT_DEPLOY_PREFIX where appropriate.

Amends 5430fb22439db9fc1ad1df4cbf0319b63346b0a5

Pick-to: 6.8
Fixes: QTBUG-135620
Task-number: QTBUG-109553
Change-Id: Iea1c0b69ba93fa5e81c463df57f8c2e19703a66a
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit ae4f9fe0cf6acded39020b8fbefd35df20ffff7d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2025-04-07 10:04:54 +02:00 committed by Qt Cherry-pick Bot
parent 1f354786f1
commit 84841f3bb0

View File

@ -286,15 +286,22 @@ function(_qt_internal_generic_deployqt)
"${file_path}"
)
get_filename_component(destination "${destination}" DIRECTORY)
string(PREPEND destination "${CMAKE_INSTALL_PREFIX}/${arg_PLUGINS_DIR}/")
file(INSTALL ${file_path} DESTINATION ${destination})
string(PREPEND destination "${arg_PLUGINS_DIR}/")
# CMAKE_INSTALL_PREFIX does not contain $ENV{DESTDIR}, whereas QT_DEPLOY_PREFIX does.
# The install_ variant should be used in file(INSTALL) to avoid double DESTDIR in paths.
# Other code should reference the dest_ variant instead.
set(install_path "${CMAKE_INSTALL_PREFIX}/${destination}")
set(destdir_path "${QT_DEPLOY_PREFIX}/${destination}")
file(INSTALL ${file_path} DESTINATION "${install_path}")
if(__QT_DEPLOY_MUST_ADJUST_PLUGINS_RPATH)
get_filename_component(file_name ${file_path} NAME)
file(RELATIVE_PATH rel_lib_dir "${destination}"
file(RELATIVE_PATH rel_lib_dir "${destdir_path}"
"${QT_DEPLOY_PREFIX}/${QT_DEPLOY_LIB_DIR}")
_qt_internal_set_rpath(
FILE "${destination}/${file_name}"
FILE "${destdir_path}/${file_name}"
NEW_RPATH "${rpath_origin}/${rel_lib_dir}"
)
endif()