From 15b26935fca4ab14298abdcc70b3cb15b6cca195 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 19 Apr 2021 16:13:14 +0200 Subject: 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 e6527e2f73663205a0f36feac5a7feda47fba152 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. Pick-to: dev 6.1 Fixes: QTBUG-92890 Change-Id: I96fb0655e02c5c695722b7e01a32e209cbdea4cc Reviewed-by: Alexandru Croitor --- cmake/QtBuildInternalsExtra.cmake.in | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/cmake/QtBuildInternalsExtra.cmake.in b/cmake/QtBuildInternalsExtra.cmake.in index fd91019ed7..5d5195e022 100644 --- a/cmake/QtBuildInternalsExtra.cmake.in +++ b/cmake/QtBuildInternalsExtra.cmake.in @@ -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. -- cgit v1.2.3