summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2022-04-13 14:57:34 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2022-05-23 12:11:50 +0200
commitacfa25588b25948ae2c5aa872f0b6470fa2b57fa (patch)
tree19a938bc6fcbe33cb07ec2356e3230a43e85116e /cmake
parent5ba7a825a0787aaaddcb575937a5153b606ca43b (diff)
CMake: Allow no install + custom on-device prefix for desktop builds
Allow such a combination - staging prefix (CMAKE_STAGING_PREFIX / -extprefix) set to the qtbase build dir - install prefix (CMAKE_INSTALL_PREFIX / -prefix / on-device prefix) set to some custom location even for non-cross builds. An example would be configure -prefix /usr \ -extprefix ~/qt/qtbase_build_dir CMake will put the Qt libraries in the qtbase build dir, ninja install will not be required, but ultimately in order to run applications, the Qt libraries are expected to be in /usr. Support for this scenario was originally added for cross-builds in 062318feb2d3b7598409c7e81e4459c2f4607764 , but not desktop builds. Such a build is useful when you want to have install rpaths different from where Qt is initially installed to (the staging prefix). This case doesn't really happen often when targeting desktop platforms, it's mostly used for cross-compilation (e.g yocto). Being able to have the same setup with a desktop build is nevertheless useful for faster iteration on build system issues in such a scenario. Amends 062318feb2d3b7598409c7e81e4459c2f4607764 Change-Id: I42be3628a30025f14eebaf0a79401b54e95cde26 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io> (cherry picked from commit f3483e6b962efd03ccf7633cb68f0c3b91b5c07c)
Diffstat (limited to 'cmake')
-rw-r--r--cmake/QtBuild.cmake2
-rw-r--r--cmake/QtBuildInternals/QtBuildInternalsConfig.cmake10
-rw-r--r--cmake/QtSetup.cmake5
3 files changed, 10 insertions, 7 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake
index 0a0fc9d355..4c15d1d7e1 100644
--- a/cmake/QtBuild.cmake
+++ b/cmake/QtBuild.cmake
@@ -140,7 +140,7 @@ qt_configure_process_path(INSTALL_DESCRIPTIONSDIR
"${INSTALL_DATADIR}/modules"
"Module description files directory")
-if(CMAKE_CROSSCOMPILING AND NOT "${CMAKE_STAGING_PREFIX}" STREQUAL "")
+if(NOT "${CMAKE_STAGING_PREFIX}" STREQUAL "")
set(QT_STAGING_PREFIX "${CMAKE_STAGING_PREFIX}")
else()
set(QT_STAGING_PREFIX "${CMAKE_INSTALL_PREFIX}")
diff --git a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
index a66b92aa4b..e9ea74c19c 100644
--- a/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
+++ b/cmake/QtBuildInternals/QtBuildInternalsConfig.cmake
@@ -643,15 +643,21 @@ function(qt_compute_relative_path_from_cmake_config_dir_to_prefix)
#
# Similar code exists in Qt6CoreConfigExtras.cmake.in and src/corelib/CMakeLists.txt which
# might not be needed anymore.
+ if(CMAKE_STAGING_PREFIX)
+ set(__qt_prefix "${CMAKE_STAGING_PREFIX}")
+ else()
+ set(__qt_prefix "${CMAKE_INSTALL_PREFIX}")
+ endif()
+
if(QT_WILL_INSTALL)
get_filename_component(clean_config_prefix
- "${CMAKE_INSTALL_PREFIX}/${QT_CONFIG_INSTALL_DIR}" ABSOLUTE)
+ "${__qt_prefix}/${QT_CONFIG_INSTALL_DIR}" ABSOLUTE)
else()
get_filename_component(clean_config_prefix "${QT_CONFIG_BUILD_DIR}" ABSOLUTE)
endif()
file(RELATIVE_PATH
qt_path_from_cmake_config_dir_to_prefix
- "${clean_config_prefix}" "${CMAKE_INSTALL_PREFIX}")
+ "${clean_config_prefix}" "${__qt_prefix}")
set(qt_path_from_cmake_config_dir_to_prefix "${qt_path_from_cmake_config_dir_to_prefix}"
PARENT_SCOPE)
endfunction()
diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake
index 6ab53c2a52..8d417e6355 100644
--- a/cmake/QtSetup.cmake
+++ b/cmake/QtSetup.cmake
@@ -137,12 +137,9 @@ if (PROJECT_NAME STREQUAL "QtBase" AND NOT QT_BUILD_STANDALONE_TESTS)
"Install path prefix, prepended onto install directories." FORCE)
unset(__qt_default_prefix)
endif()
- if(CMAKE_CROSSCOMPILING)
+ if(CMAKE_STAGING_PREFIX)
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)