sdk: use Qt's own qt.toolchain.cmake in build scripts

qt-cmake* helper build scripts by default use Qt's generated
qt.toolchain.cmake as the CMAKE_TOOLCHAIN_FILE. Keep this behavior and
patch qt.toolchain.cmake so that will chain-load our Qt6Toolchain.cmake.

qt.toolchain.cmake includes bits that are needed for the conan
integration to work correctly with the sdk.

Pick-to: 6.3 6.2
Change-Id: I89a5e152324178151ba8a5ab4734d542fa4c995c
Reviewed-by: Mikko Gronoff <mikko.gronoff@qt.io>
This commit is contained in:
Samuli Piippo 2021-12-17 14:55:56 +02:00
parent 0e598fb241
commit 7f3cb3884d
3 changed files with 35 additions and 13 deletions

View File

@ -96,15 +96,9 @@ set(CMAKE_TOOLCHAIN_FILE "${SDKPATHNATIVE}/usr/share/cmake/OEToolchainConfig.cma
include("\${CMAKE_TOOLCHAIN_FILE}")
EOF
# override qt-cmake
cat > ${SDK_OUTPUT}${SDKPATHNATIVE}${QT6_INSTALL_BINDIR}/qt-cmake <<EOF
#!/bin/sh
cmake_path="${SDKPATHNATIVE}${bindir}/cmake"
toolchain_path="${SDKPATHNATIVE}/usr/share/cmake/Qt6Toolchain.cmake"
exec "\$cmake_path" -DCMAKE_TOOLCHAIN_FILE="\$toolchain_path" "\$@"
EOF
# and use that from the default toolchain file qt.toolchain.cmake
sed -i ${SDK_OUTPUT}${SDKPATHNATIVE}${QT6_INSTALL_LIBDIR}/cmake/Qt6/qt.toolchain.cmake \
-e 's|/.*/toolchain.cmake|${SDKPATHNATIVE}/usr/share/cmake/Qt6Toolchain.cmake|'
}
create_qt6_sdk_files:append:sdkmingw32() {

View File

@ -0,0 +1,29 @@
From c15033fd4df14b08fc28ec8da61c990801c7e411 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
The calculated paths for QT_TOOLCHAIN_RELOCATABLE paths point to
host sysroot which must not be used when cross-compiling other projects.
Upstream-Status: Inappropriate [embedded specific]
---
cmake/qt.toolchain.cmake.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in
index 5e9acd66b8..451de99633 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_
# 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.
-list(PREPEND CMAKE_PREFIX_PATH "${QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR}")
-list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX}")
+#list(PREPEND CMAKE_PREFIX_PATH "${QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR}")
+#list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_TOOLCHAIN_RELOCATABLE_INSTALL_PREFIX}")
# Let CMake load our custom platform modules.
# CMake-provided platform modules take precedence.

View File

@ -17,6 +17,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://0001-catch_p_p.h-don-t-use-MINSIGSTKSZ.patch \
file://0005-Exclude-sources-from-HEADER_MODULE-if-cmake-version-.patch \
"
@ -155,10 +156,8 @@ set(QT_HOST_PATH "\$ENV{OECORE_NATIVE_SYSROOT}/usr" CACHE PATH "")
set(QT_BUILD_TOOLS_WHEN_CROSSCOMPILING "TRUE" CACHE BOOL "")
EOF
sed -i ${D}${QT6_INSTALL_BINDIR}/* \
-e 's|${RECIPE_SYSROOT_NATIVE}|${SDKPATHNATIVE}|' \
-e '/^toolchain_path=/s|.*|toolchain_path=${SDKPATHNATIVE}/usr/share/cmake/Qt6Toolchain.cmake|'
sed -i ${D}${QT6_INSTALL_BINDIR}/* ${D}${QT6_INSTALL_LIBDIR}/cmake/Qt6/qt.toolchain.cmake \
-e 's|${RECIPE_SYSROOT_NATIVE}|${SDKPATHNATIVE}|'
}
INSANE_SKIP:${PN}-ptest += "arch"