From 8b5cce6911a0854cd794c23e53908e8ddcc3843f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 11 Jul 2022 15:11:35 +0200 Subject: [PATCH] CMake: Fix prefix propagation for relocated Qt installations Consider qtbase built with CMAKE_STAGING_PREFIX=/foo on Windows. If /foo was moved to /bar, non-qtbase repositories did get a staging prefix with drive letter assigned. This is undesirable when DESTDIR is used on installation. Change the implementation of qt_internal_new_prefix to remove the drive letter from the "new prefix" if the "old prefix" did not have a drive letter. Change-Id: I6fb17e690b264920b0dd4204e3b3c30794c7e76e Reviewed-by: Alexandru Croitor --- cmake/QtBuildInternalsExtra.cmake.in | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/cmake/QtBuildInternalsExtra.cmake.in b/cmake/QtBuildInternalsExtra.cmake.in index 8257bacf74d..d108fbd1cd3 100644 --- a/cmake/QtBuildInternalsExtra.cmake.in +++ b/cmake/QtBuildInternalsExtra.cmake.in @@ -18,15 +18,14 @@ get_filename_component(QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX # new_prefix: the new prefix for this repository # orig_prefix: the prefix that was used when qtbase was configured # -# On Windows hosts, this function makes sure that 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. +# On Windows hosts: if the original prefix does not start with a drive letter, this function removes +# the drive letter from the new prefix. This is needed for installation with DESTDIR set. function(qt_internal_new_prefix out_var new_prefix orig_prefix) if(CMAKE_HOST_WIN32) - get_filename_component(real_new_prefix "${new_prefix}" REALPATH) - get_filename_component(real_orig_prefix "${orig_prefix}" REALPATH) - if(real_new_prefix STREQUAL real_orig_prefix) - set(new_prefix "${orig_prefix}") + set(drive_letter_regexp "^[a-zA-Z]:") + if(new_prefix MATCHES "${drive_letter_regexp}" + AND NOT orig_prefix MATCHES "${drive_letter_regexp}") + string(SUBSTRING "${new_prefix}" 2 -1 new_prefix) endif() endif() set(${out_var} "${new_prefix}" PARENT_SCOPE)