From d6e01ae05c3695aaf7d0d434718154b6ff151e32 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 22 Jun 2021 16:00:03 +0200 Subject: [PATCH] Fix QT_HOST_DATA for builds setting INSTALL_MKSPECSDIR In a Qt build that was configured with INSTALL_MKSPECSDIR set to something different than INSTALL_DATADIR, the qmake property QT_HOST_DATA was wrong. Consequently, mkspecs could not be loaded, rendering qmake dysfunctional. The reason was that we considered every QT_HOST_xxx property to have the same value as QT_INSTALL_xxx in a non-cross build. This is not true for QT_HOST_DATA, because users might want to set INSTALL_DATADIR to "foo" but INSTALL_MKSPECSDIR to "bar/mkspecs". Move the unused determination of the host data dir to the QtLibraryInfo lib and handle QT_HOST_DATA specially. Fixes: QTBUG-94591 Pick-to: 6.2 Change-Id: I2c44cda8405ff1d14391254fcd1d9b1361cb5855 Reviewed-by: Alexandru Croitor --- cmake/QtQmakeHelpers.cmake | 6 ------ qmake/CMakeLists.txt | 8 ++++++++ qmake/qmakelibraryinfo.cpp | 7 ++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/cmake/QtQmakeHelpers.cmake b/cmake/QtQmakeHelpers.cmake index 0a2c5b1531..47a41d9236 100644 --- a/cmake/QtQmakeHelpers.cmake +++ b/cmake/QtQmakeHelpers.cmake @@ -25,12 +25,6 @@ function(qt_generate_qconfig_cpp in_file out_file) set(QT_CONFIG_STR_OFFSETS "") set(QT_CONFIG_STRS "") - # Chop off the "/mkspecs" part of INSTALL_MKSPECSDIR - get_filename_component(hostdatadir "${INSTALL_MKSPECSDIR}" DIRECTORY) - if("${hostdatadir}" STREQUAL "") - set(hostdatadir ".") - endif() - # Start first part. qt_add_string_to_qconfig_cpp("${INSTALL_DOCDIR}") qt_add_string_to_qconfig_cpp("${INSTALL_INCLUDEDIR}") diff --git a/qmake/CMakeLists.txt b/qmake/CMakeLists.txt index dbe50552cf..d35d981c99 100644 --- a/qmake/CMakeLists.txt +++ b/qmake/CMakeLists.txt @@ -22,6 +22,13 @@ target_include_directories(QtLibraryInfo PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/library" ) + +# Chop off the "/mkspecs" part of INSTALL_MKSPECSDIR +get_filename_component(hostdatadir "${INSTALL_MKSPECSDIR}" DIRECTORY) +if("${hostdatadir}" STREQUAL "") + set(hostdatadir ".") +endif() + target_compile_definitions(QtLibraryInfo PUBLIC PROEVALUATOR_FULL QT_BUILD_QMAKE @@ -33,6 +40,7 @@ target_compile_definitions(QtLibraryInfo PUBLIC QT_VERSION_PATCH=${PROJECT_VERSION_PATCH} # special case QT_HOST_MKSPEC="${QT_QMAKE_HOST_MKSPEC}" QT_TARGET_MKSPEC="${QT_QMAKE_TARGET_MKSPEC}" + QT_HOST_DATADIR="${hostdatadir}" ) qt_set_common_target_properties(QtLibraryInfo) diff --git a/qmake/qmakelibraryinfo.cpp b/qmake/qmakelibraryinfo.cpp index 257d23cbb6..b501cfc5f6 100644 --- a/qmake/qmakelibraryinfo.cpp +++ b/qmake/qmakelibraryinfo.cpp @@ -182,7 +182,12 @@ static QString storedPath(int loc) if (loc < QMakeLibraryInfo::FirstHostPath) { result = QLibraryInfo::path(static_cast(loc)); } else if (loc <= QMakeLibraryInfo::LastHostPath) { - result = QLibraryInfo::path(hostToTargetPathEnum(loc)); + if (loc == QMakeLibraryInfo::HostDataPath) { + // Handle QT_HOST_DATADIR specially. It is not necessarily equal to QT_INSTALL_DATA. + result = QT_HOST_DATADIR; + } else { + result = QLibraryInfo::path(hostToTargetPathEnum(loc)); + } } else if (loc == QMakeLibraryInfo::SysrootPath) { // empty result } else if (loc == QMakeLibraryInfo::SysrootifyPrefixPath) {