CMake: Fix rpath adjustment when deploying QML plugins

If Qt is configured with a custom value for INSTALL_QMLDIR, e.g. via
"configure -qmldir lib/qml", then we must adjust the rpath for QML
plugins. Otherwise they won't be able to load Qt libraries.

We had general code that adjusts the rpath for plugins, but that only
triggered if INSTALL_LIBDIR was different from the user project's
CMAKE_INSTALL_LIBDIR.

Now, we always adjust the rpath of plugins on Linux. The operation is
cheap, and I don't quite see how to add a robust condition for all
desired cases.

Pick-to: 6.8
Fixes: QTBUG-125223
Change-Id: Ib511fbc2b733deac804191773e56be9b6adf5e68
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit ecd63d469f453d4fef6e807388e68451cdc2c043)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Joerg Bornemann 2025-05-13 16:27:11 +02:00 committed by Qt Cherry-pick Bot
parent cde02af8f6
commit 19cd476da7

View File

@ -3068,10 +3068,10 @@ function(_qt_internal_setup_deploy_support)
# Check whether we will have to adjust the RPATH of plugins.
if("${QT_DEPLOY_FORCE_ADJUST_RPATHS}" STREQUAL "")
set(must_adjust_plugins_rpath "")
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows"
AND NOT CMAKE_INSTALL_LIBDIR STREQUAL QT6_INSTALL_LIBS)
if(UNIX AND NOT APPLE)
set(must_adjust_plugins_rpath ON)
else()
set(must_adjust_plugins_rpath OFF)
endif()
else()
set(must_adjust_plugins_rpath "${QT_DEPLOY_FORCE_ADJUST_RPATHS}")