SDK: make sure initial qt host path is absolute

__qt_toolchain_initial_qt_host_path is assigned to QT_HOST_PATH and then
to CMAKE_FIND_ROOT_PATH. Problems occurs if that path is relative.
CMake doesn't do relative path resolving by default in find_package,
when doing sub-prefix checking between find root path and prefix path.

Patch the qt.toochain.cmake so that it always uses absolute path for
__qt_toolchain_initial_qt_host_path, but make it still based on its
own location.

Pick-to: 6.3 6.2
Fixes: QTBUG-103818
Change-Id: I1cce126c243c017b1cecd14a0fd616cb0328fe6d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Samuli Piippo 2022-06-02 04:36:49 +00:00
parent 723b6b805b
commit ea541e308f
2 changed files with 26 additions and 9 deletions

View File

@ -1,22 +1,25 @@
From c15033fd4df14b08fc28ec8da61c990801c7e411 Mon Sep 17 00:00:00 2001
From e9bb85a781536a048adc85b1ec5a02d7d10d21fb 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] Do not use QT_TOOLCHAIN_RELOCATABLE paths in
qt.toolchain.cmake
Subject: [PATCH] Fix qt.toolchain.cmake for SDK use
Set initial host path based on the location of the qt.toolchain.cmake file.
This helps us avoid need to relocate the file in SDK.
The calculated paths for QT_TOOLCHAIN_RELOCATABLE paths point to
host sysroot which must not be used when cross-compiling other projects.
Change-Id: I52aa2a10d2a13fd27d6bf8b4af6dc1833c7a286a
Upstream-Status: Inappropriate [embedded specific]
---
cmake/qt.toolchain.cmake.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
cmake/qt.toolchain.cmake.in | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in
index 5e9acd66b8..451de99633 100644
index 6e37ae0281..1eba4d8c7c 100644
--- a/cmake/qt.toolchain.cmake.in
+++ b/cmake/qt.toolchain.cmake.in
@@ -68,8 +68,8 @@ get_filename_component(QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR "${CMAKE_CURRENT_LIST_
@@ -71,8 +71,8 @@ get_filename_component(QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR "${CMAKE_CURRENT_LIST_
# Instead of collapsing the search prefix (which is the case when one is a subdir of the other),
# it concatenates them creating an invalid path. Workaround it by setting the root path to the
# Qt install prefix, and the prefix path to the lib/cmake subdir.
@ -27,3 +30,18 @@ index 5e9acd66b8..451de99633 100644
# Let CMake load our custom platform modules.
# CMake-provided platform modules take precedence.
@@ -162,10 +162,10 @@ if(DEFINED QT_REQUIRE_HOST_PATH_CHECK)
else()
set(__qt_toolchain_host_path_required "@qt_host_path_required@")
endif()
-set(__qt_toolchain_initial_qt_host_path
- "@qt_host_path_absolute@")
-set(__qt_toolchain_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_HOST_PATH precedence:
# - cache variable / command line option

View File

@ -22,7 +22,7 @@ SRC_URI += "\
file://0001-Add-linux-oe-g-platform.patch \
file://0002-qlibraryinfo-allow-to-set-qt.conf-from-the-outside-u.patch \
file://0003-tests-disable-failing-tests.patch \
file://0004-Do-not-use-QT_TOOLCHAIN_RELOCATABLE-paths-in-qt.tool.patch \
file://0004-Fix-qt.toolchain.cmake-for-SDK-use.patch \
"
DEPENDS += "\
@ -171,7 +171,6 @@ EOF
RELPATH=${@os.path.relpath(d.getVar('prefix') + '/share/cmake/Qt6Toolchain.cmake', d.getVar('QT6_INSTALL_LIBDIR') + '/cmake/Qt6')}
sed -i ${D}${QT6_INSTALL_LIBDIR}/cmake/Qt6/qt.toolchain.cmake \
-e 's|${RECIPE_SYSROOT_NATIVE}|\${CMAKE_CURRENT_LIST_DIR}/../../../..|' \
-e "s|/.*/toolchain.cmake|\${CMAKE_CURRENT_LIST_DIR}/$RELPATH|"
}