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.

Pick-to: 6.5
Task-number: QTBUG-109553
Change-Id: I8f06d81968fa0de4f17c4f8bc9b17cc052da4c12
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Joerg Bornemann 2022-12-21 09:49:04 +01:00
parent c203ec2720
commit 1f142d9038

View File

@ -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)