From 6d75c0dea686102a0629b5e7de26d126a097f3ac Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 21 Dec 2022 09:49:04 +0100 Subject: [PATCH] CMake: Avoid repeating DESTDIR when deploying Qt libs and plugins Let CMAKE_INSTALL_PREFIX be "/usr/local", and consider a project with a call to qt_generate_deploy_app_script. Installing the project with DESTDIR set to "/tmp/bla" would install the project targets to "/tmp/bla/usr/local" but the Qt libraries to "/tmp/bla/tmp/bla/usr/local". That happened, because we used QT_DEPLOY_PREFIX as DESTINATION in file(INSTALL). QT_DEPLOY_PREFIX starts with $ENV{DESTDIR} and file(INSTALL) also prepends DESTDIR. The value of QT_DEPLOY_PREFIX is controlled by CMAKE_INSTALL_PREFIX. Use the latter as DESTINATION in file(INSTALL) calls. Task-number: QTBUG-109553 Change-Id: I8f06d81968fa0de4f17c4f8bc9b17cc052da4c12 Reviewed-by: Alexey Edelev (cherry picked from commit 1f142d903835a86996a00c2ee32689c7fb10c1e4) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/Qt6CoreDeploySupport.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/Qt6CoreDeploySupport.cmake b/src/corelib/Qt6CoreDeploySupport.cmake index 2fbeb5e96f5..0b7b702a4e6 100644 --- a/src/corelib/Qt6CoreDeploySupport.cmake +++ b/src/corelib/Qt6CoreDeploySupport.cmake @@ -239,7 +239,7 @@ function(_qt_internal_generic_deployqt) # Deploy the Qt libraries. file(INSTALL ${resolved} - DESTINATION "${QT_DEPLOY_PREFIX}/${arg_LIB_DIR}" + DESTINATION "${CMAKE_INSTALL_PREFIX}/${arg_LIB_DIR}" FOLLOW_SYMLINK_CHAIN ) @@ -255,7 +255,7 @@ function(_qt_internal_generic_deployqt) "${file_path}" ) get_filename_component(destination "${destination}" DIRECTORY) - string(PREPEND destination "${QT_DEPLOY_PREFIX}/${arg_PLUGINS_DIR}/") + string(PREPEND destination "${CMAKE_INSTALL_PREFIX}/${arg_PLUGINS_DIR}/") file(INSTALL ${file_path} DESTINATION ${destination}) if(__QT_DEPLOY_MUST_ADJUST_PLUGINS_RPATH)