From 8a56b4ad9bcbafefd8de0caf102c300b7771e57b Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 13 Apr 2022 18:52:56 +0200 Subject: [PATCH] CMake: Embed an empty qt_prfxpath if Qt is relocatable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When Qt is configured as relocatable, QT_CONFIGURE_PREFIX_PATH_STR -> qt_configure_prefix_path_str -> qt_prfxpath is not used in relevant code paths. Specifically qlibraryinfo.cpp getPrefix() uses getRelocatablePrefix() instead of QT_CONFIGURE_PREFIX_PATH. Thus, when Qt is configured as relocatable, set qt_prfxpath to an empty string. This avoids embedding a CI path like /home/qt/work/install into the official packages, which makes reproducible builds a closer reality. Change-Id: I9209b08e651ad0b7fdc4049df333e0978e05f1f5 Reviewed-by: Jörg Bornemann Reviewed-by: Edward Welbourne --- cmake/QtQmakeHelpers.cmake | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/cmake/QtQmakeHelpers.cmake b/cmake/QtQmakeHelpers.cmake index 0f623254fb..229c3a0fb4 100644 --- a/cmake/QtQmakeHelpers.cmake +++ b/cmake/QtQmakeHelpers.cmake @@ -57,11 +57,18 @@ function(qt_generate_qconfig_cpp in_file out_file) # Expected output is something like # C:/work/qt/install # so it includes a drive letter and forward slashes. - set(QT_CONFIGURE_PREFIX_PATH_STR "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}") - if(CMAKE_HOST_WIN32) - get_filename_component( - QT_CONFIGURE_PREFIX_PATH_STR - "${QT_CONFIGURE_PREFIX_PATH_STR}" REALPATH) + if(QT_FEATURE_relocatable) + # A relocatable Qt does not need a hardcoded prefix path. + # This makes reproducible builds a closer reality, because we don't embed a CI path + # into the binaries. + set(QT_CONFIGURE_PREFIX_PATH_STR "") + else() + set(QT_CONFIGURE_PREFIX_PATH_STR "${QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX}") + if(CMAKE_HOST_WIN32) + get_filename_component( + QT_CONFIGURE_PREFIX_PATH_STR + "${QT_CONFIGURE_PREFIX_PATH_STR}" REALPATH) + endif() endif() configure_file(${in_file} ${out_file} @ONLY)