From ae4f9fe0cf6acded39020b8fbefd35df20ffff7d Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 7 Apr 2025 10:04:54 +0200 Subject: [PATCH] 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 6.9 Fixes: QTBUG-135620 Task-number: QTBUG-109553 Change-Id: Iea1c0b69ba93fa5e81c463df57f8c2e19703a66a Reviewed-by: Joerg Bornemann --- src/corelib/Qt6CoreDeploySupport.cmake | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/corelib/Qt6CoreDeploySupport.cmake b/src/corelib/Qt6CoreDeploySupport.cmake index 4c259739209..f2a0f95ec66 100644 --- a/src/corelib/Qt6CoreDeploySupport.cmake +++ b/src/corelib/Qt6CoreDeploySupport.cmake @@ -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()