From ce9efcf4a901fbb245fc7a9a6605b8c8fc25e91d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 13 Jul 2020 09:22:46 +0200 Subject: [PATCH] CMake: Fix QT_STAGING_PREFIX for repos other than qtbase For repositories other than qtbase the QT_STAGING_PREFIX was empty, because it was only determined in qtbase. Also, we save the CMAKE_STAGING_PREFIX in the Qt6BuildInternals package and set this variable if it's not explicitly set by the user. As with CMAKE_INSTALL_PREFIX this behavior can be prevented by defining QT_BUILD_INTERNALS_NO_FORCE_SET_STAGING_PREFIX=ON. Change-Id: I73100abbef24f5d3fb8f82029d0374176edc8048 Reviewed-by: Alexandru Croitor --- cmake/QtBuild.cmake | 6 ++++++ cmake/QtPostProcess.cmake | 12 ++++++++++++ cmake/QtSetup.cmake | 2 -- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index 404415a99f..7ad7e6e252 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -125,6 +125,12 @@ qt_configure_process_path(INSTALL_DESCRIPTIONSDIR "${INSTALL_DATADIR}/modules" "Module description files directory") +if(CMAKE_CROSSCOMPILING AND NOT "${CMAKE_STAGING_PREFIX}" STREQUAL "") + set(QT_STAGING_PREFIX "${CMAKE_STAGING_PREFIX}") +else() + set(QT_STAGING_PREFIX "${CMAKE_INSTALL_PREFIX}") +endif() + function(qt_internal_set_up_global_paths) # Compute the values of QT_BUILD_DIR, QT_INSTALL_DIR, QT_CONFIG_BUILD_DIR, QT_CONFIG_INSTALL_DIR # taking into account whether the current build is a prefix build or a non-prefix build, diff --git a/cmake/QtPostProcess.cmake b/cmake/QtPostProcess.cmake index 73d9d2dcd6..b6cbe57d41 100644 --- a/cmake/QtPostProcess.cmake +++ b/cmake/QtPostProcess.cmake @@ -459,6 +459,18 @@ endif()\n") "set(OPENSSL_ROOT_DIR \"${openssl_root_cmake_path}\" CACHE STRING \"\")\n") endif() + if(NOT "${CMAKE_STAGING_PREFIX}" STREQUAL "") + string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS + " +# If no explicit CMAKE_STAGING_PREFIX is provided, force set the original Qt staging prefix, +if(\"$\{CMAKE_STAGING_PREFIX}\" STREQUAL \"\" + AND NOT QT_BUILD_INTERNALS_NO_FORCE_SET_STAGING_PREFIX) + set(CMAKE_STAGING_PREFIX \"${CMAKE_STAGING_PREFIX}\" CACHE PATH + \"Staging path prefix, prepended onto install directories on the host machine.\" FORCE) +endif() +") + endif() + qt_generate_install_prefixes(install_prefix_content) string(APPEND QT_EXTRA_BUILD_INTERNALS_VARS "${install_prefix_content}") diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake index 16b334fac1..ede764b542 100644 --- a/cmake/QtSetup.cmake +++ b/cmake/QtSetup.cmake @@ -87,8 +87,6 @@ if (PROJECT_NAME STREQUAL "QtBase" AND NOT QT_BUILD_STANDALONE_TESTS) else() set(__qt_will_install_value ON) endif() - set(QT_STAGING_PREFIX "${__qt_prefix}" CACHE INTERNAL - "Install prefix on the build machine. Either CMAKE_INSTALL_PREFIX or CMAKE_STAGING_PREFIX.") set(QT_WILL_INSTALL ${__qt_will_install_value} CACHE BOOL "Boolean indicating if doing a Qt prefix build (vs non-prefix build)." FORCE) unset(__qt_prefix)