CMake: Embed an empty qt_prfxpath if Qt is relocatable

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 <joerg.bornemann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
Alexandru Croitor 2022-04-13 18:52:56 +02:00
parent 251033fb0a
commit 8a56b4ad9b

View File

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