Fix DESTDIR handling on Windows for Qt modules != qtbase

On the CI system, we build qtbase with CMAKE_INSTALL_PREFIX set to a
path without a drive letter to support DESTDIR when installing.
Other Qt modules are built without CMAKE_INSTALL_PREFIX set. The
Qt6BuildInternals package provides a default value.

Since commit e6527e2f73 this default
prefix is calculated from the current installation location. This
default prefix however has a drive letter, breaking DESTDIR support.

Broken DESTDIR support in this case means for Android that file(INSTALL)
can properly install but stripping will silently fail.

We now compare the "real path" of the original prefix from qtbase and
the calculated prefix. When they're equal, we use the original
CMAKE_INSTALL_PREFIX.

Fixes: QTBUG-92890
Change-Id: I96fb0655e02c5c695722b7e01a32e209cbdea4cc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 15b26935fca4ab14298abdcc70b3cb15b6cca195)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Joerg Bornemann 2021-04-19 16:13:14 +02:00 committed by Qt Cherry-pick Bot
parent 3c74ee5682
commit b226e99c71

View File

@ -21,9 +21,25 @@ get_filename_component(QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX
# This is an attempt to support Conan, aka handle installation of modules into a
# different installation prefix than the original one. Also allow to opt out via a special variable.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND
NOT QT_BUILD_INTERNALS_NO_FORCE_SET_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}" CACHE PATH
NOT QT_BUILD_INTERNALS_NO_FORCE_SET_INSTALL_PREFIX)
set(qtbi_orig_prefix "@CMAKE_INSTALL_PREFIX@")
set(qtbi_new_prefix "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}")
if(CMAKE_HOST_WIN32)
# Make sure we use exactly the original prefix if it points to the same directory as the new
# one. This is needed for the case where the original prefix is passed without drive letter
# to support installing with DESTDIR set.
file(REAL_PATH "${qtbi_orig_prefix}" qtbi_real_orig_prefix)
file(REAL_PATH "${qtbi_new_prefix}" qtbi_real_new_prefix)
if(qtbi_real_orig_prefix STREQUAL qtbi_real_new_prefix)
set(qtbi_new_prefix "${qtbi_orig_prefix}")
endif()
endif()
set(CMAKE_INSTALL_PREFIX "${qtbi_new_prefix}" CACHE PATH
"Install path prefix, prepended onto install directories." FORCE)
unset(qtbi_orig_prefix)
unset(qtbi_real_orig_prefix)
unset(qtbi_new_prefix)
unset(qtbi_real_new_prefix)
endif()
# Propagate developer builds to other modules via BuildInternals package.