From 062318feb2d3b7598409c7e81e4459c2f4607764 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 22 Jun 2020 18:01:30 +0200 Subject: [PATCH] CMake: Fix non-prefix build detection when CMAKE_STAGING_PREFIX is set It wasn't possible to create a cross, non-prefix build with CMAKE_INSTALL_PREFIX set to something else but the qtbase build dir and CMAKE_STAGING_PREFIX set to the qtbase build dir. This would be equivalent to configure -prefix /usr \ -extprefix ~/my/qtbase/build/dir Fix this by comparing the qtbase build dir against CMAKE_STAGING_PREFIX if it is set. We also have to adjust the QT_BUILD_DIR variable in a similar way. Change-Id: Iaba5cf0f6954ae4b15d8af1fc62634f5d7f68835 Reviewed-by: Alexandru Croitor --- cmake/QtBuild.cmake | 15 ++++++++++++--- cmake/QtSetup.cmake | 17 +++++++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index c3a9d0135d..bde23072ea 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -145,8 +145,13 @@ function(qt_internal_set_up_global_paths) set(QT_BUILD_DIR "${QtBase_BINARY_DIR}") set(QT_INSTALL_DIR "") else() - set(QT_BUILD_DIR "${QtBase_BINARY_DIR}") - set(QT_INSTALL_DIR "${QtBase_BINARY_DIR}") + if("${CMAKE_STAGING_PREFIX}" STREQUAL "") + set(QT_BUILD_DIR "${QtBase_BINARY_DIR}") + set(QT_INSTALL_DIR "${QtBase_BINARY_DIR}") + else() + set(QT_BUILD_DIR "${CMAKE_STAGING_PREFIX}") + set(QT_INSTALL_DIR "${CMAKE_STAGING_PREFIX}") + endif() endif() else() if(QT_WILL_INSTALL) @@ -157,7 +162,11 @@ function(qt_internal_set_up_global_paths) else() # When doing a non-prefix build, both the build dir and install dir are the same, # pointing to the qtbase build dir. - set(QT_BUILD_DIR "${CMAKE_INSTALL_PREFIX}") + if("${CMAKE_STAGING_PREFIX}" STREQUAL "") + set(QT_BUILD_DIR "${CMAKE_INSTALL_PREFIX}") + else() + set(QT_BUILD_DIR "${CMAKE_STAGING_PREFIX}") + endif() set(QT_INSTALL_DIR "${QT_BUILD_DIR}") endif() endif() diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake index b23b9924e0..bdb93e6fd0 100644 --- a/cmake/QtSetup.cmake +++ b/cmake/QtSetup.cmake @@ -66,21 +66,30 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN 1) # This detection only happens when building qtbase, and later is propagated via the generated # QtBuildInternalsExtra.cmake file. if (PROJECT_NAME STREQUAL "QtBase" AND NOT QT_BUILD_STANDALONE_TESTS) - if((CMAKE_INSTALL_PREFIX STREQUAL QtBase_BINARY_DIR) OR - (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND FEATURE_developer_build)) - - set(__qt_will_install_value OFF) + if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT AND FEATURE_developer_build) # Handle non-prefix builds by setting the CMake install prefix to point to qtbase's build # dir. # While building another repo (like qtsvg) the CMAKE_PREFIX_PATH # should be set on the command line to point to the qtbase build dir. set(CMAKE_INSTALL_PREFIX ${QtBase_BINARY_DIR} CACHE PATH "Install path prefix, prepended onto install directories." FORCE) + endif() + if(CMAKE_CROSSCOMPILING) + set(__qt_prefix "${CMAKE_STAGING_PREFIX}") + else() + set(__qt_prefix_ "") + endif() + if(__qt_prefix STREQUAL "") + set(__qt_prefix "${CMAKE_INSTALL_PREFIX}") + endif() + if(__qt_prefix STREQUAL QtBase_BINARY_DIR) + set(__qt_will_install_value OFF) else() set(__qt_will_install_value ON) endif() 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) unset(__qt_will_install_value) endif()