sdk: rework how QT_HOST_PATH is set in sdk

After qtbase change 0f8017efb6d037c4f33f947eb3c56aeafa28313c, QT_HOST_PATH
is no longer set in qt.toolchain.cmake, but it was moved to Qt6 package
cmake files. Since the package is in target sysroot, we can no longer use
its location to determine the absolute path of the host sysroot. Instead,
resolve QT_HOST_PATH now in the CMake subscripts and use them also without
the environment-setup script from Qt6Toolchain.cmake.

Pick-to: dev
Change-Id: I81d908321c0d05ab589b9340a62a45800e936252
Reviewed-by: Mikko Gronoff <mikko.gronoff@qt.io>
This commit is contained in:
Samuli Piippo 2022-08-11 17:45:20 +00:00
parent c6e8ab8bc6
commit 0b55d8ec94
3 changed files with 16 additions and 31 deletions

View File

@ -130,7 +130,12 @@ if(NOT DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT 1)
endif()
set(CMAKE_INSTALL_PREFIX "${prefix}" CACHE PATH "Install path prefix")
set(QT_BUILD_INTERNALS_NO_FORCE_SET_INSTALL_PREFIX ON CACHE BOOL "")
# Include the toolchain configuration subscripts
file( GLOB toolchain_config_files "\${CMAKE_CURRENT_LIST_DIR}/OEToolchainConfig.cmake.d/*.cmake" )
foreach(config \${toolchain_config_files})
include(\${config})
endforeach()
EOF
# resolve absolute paths at runtime

View File

@ -1,38 +1,17 @@
From a1729a003f820289c403360d43f10b7f84c5a03c Mon Sep 17 00:00:00 2001
From: Janne Juntunen <janne.juntunen@qt.io>
Date: Tue, 2 Aug 2022 11:03:08 +0300
Subject: [PATCH] Fix qt toolchain for SDK use
Set initial host path based on the location of the
QtConfigDependencies.cmake.in file. This helps us avoid need to relocate
the file in SDK.
From a4d3698a56665cc73a18fa860c862e1b04533792 Mon Sep 17 00:00:00 2001
From: Samuli Piippo <samuli.piippo@qt.io>
Date: Thu, 16 Dec 2021 13:10:48 +0200
Subject: [PATCH] Fix qt.toolchain.cmake for SDK use
The calculated paths for QT_TOOLCHAIN_RELOCATABLE paths point to
host sysroot which must not be used when cross-compiling other projects.
Change-Id: I8d23f76e6e7abb2651b414661304ad58e5edd522
Change-Id: I52aa2a10d2a13fd27d6bf8b4af6dc1833c7a286a
Upstream-Status: Inappropriate [embedded specific]
---
cmake/QtConfigDependencies.cmake.in | 6 ++++--
cmake/qt.toolchain.cmake.in | 4 ++--
2 files changed, 6 insertions(+), 4 deletions(-)
cmake/qt.toolchain.cmake.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cmake/QtConfigDependencies.cmake.in b/cmake/QtConfigDependencies.cmake.in
index c17ae28bac..4cc804c27a 100644
--- a/cmake/QtConfigDependencies.cmake.in
+++ b/cmake/QtConfigDependencies.cmake.in
@@ -1,8 +1,10 @@
set(@INSTALL_CMAKE_NAMESPACE@_FOUND FALSE)
set(__qt_platform_requires_host_info_package "@platform_requires_host_info_package@")
-set(__qt_platform_initial_qt_host_path "@qt_host_path_absolute@")
-set(__qt_platform_initial_qt_host_path_cmake_dir "@qt_host_path_cmake_dir_absolute@")
+get_filename_component(__qt_toolchain_initial_qt_host_path
+ "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
+get_filename_component(__qt_toolchain_initial_qt_host_path_cmake_dir
+ "${CMAKE_CURRENT_LIST_DIR}/../lib/cmake" ABSOLUTE)
_qt_internal_setup_qt_host_path(
"${__qt_platform_requires_host_info_package}"
diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in
index 15cf7a432e..03de9288df 100644
--- a/cmake/qt.toolchain.cmake.in

View File

@ -162,8 +162,9 @@ do_install:append() {
do_install:append:class-nativesdk() {
install -d ${D}${datadir}/cmake/OEToolchainConfig.cmake.d
RELPATH=${@os.path.relpath(d.getVar('prefix'), d.getVar('datadir') + '/cmake/OEToolchainConfig.cmake.d')}
cat > ${D}${datadir}/cmake/OEToolchainConfig.cmake.d/OEQt6Toolchain.cmake <<EOF
set(QT_HOST_PATH "\$ENV{OECORE_NATIVE_SYSROOT}/usr" CACHE PATH "")
get_filename_component(QT_HOST_PATH "\${CMAKE_CURRENT_LIST_DIR}/${RELPATH}" ABSOLUTE CACHE)
set(QT_BUILD_INTERNALS_NO_FORCE_SET_INSTALL_PREFIX ON CACHE BOOL "")
EOF