From 4f9da08b058382cf170bf3a0e14fc73c8cf4fecd Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Thu, 1 Aug 2024 17:00:41 +0200 Subject: [PATCH] CMake: Fix configuring standalone tests with a cross-compiled Qt The Qt6 package needs to be found before calling qt_build_internals_set_up_private_api, otherwise it will fail when using a cross-compiled Qt, because QT_HOST_PATH will not be set. The error is: CMake Error at qtbase/cmake/QtBuildHelpers.cmake:341 (message): You need to set QT_HOST_PATH to cross compile Qt. Call Stack (most recent call first): cmake/QtBuildHelpers.cmake:444 (qt_internal_check_host_path_set_for_cross_compiling) cmake/QtBuild.cmake:4 (qt_internal_setup_build_and_global_variables) cmake/QtSetup.cmake:6 (include) cmake/QtBuildRepoHelpers.cmake:21 (include) lib/cmake/Qt6BuildInternals/QtStandaloneTestTemplateProject/Main.cmake:7 (qt_build_internals_set_up_private_api) cmake/QtBuildRepoHelpers.cmake:1036 (include) cmake/QtBuildRepoHelpers.cmake:1053 (qt_internal_setup_standalone_test_when_called_as_a_find_package_component) lib/cmake/Qt6BuildInternals/Qt6BuildInternalsConfig.cmake:68 (qt_internal_setup_build_internals) CMakeLists.txt:11 (find_package) Pick-to: 6.5 6.7 6.8 Fixes: QTBUG-127668 Change-Id: I2fb3df05ce7aed3949d428d98657fe61de723abd Reviewed-by: Alexey Edelev --- .../QtStandaloneTestTemplateProject/Main.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmake/QtBuildInternals/QtStandaloneTestTemplateProject/Main.cmake b/cmake/QtBuildInternals/QtStandaloneTestTemplateProject/Main.cmake index bd0984f3145..fe33fb4b554 100644 --- a/cmake/QtBuildInternals/QtStandaloneTestTemplateProject/Main.cmake +++ b/cmake/QtBuildInternals/QtStandaloneTestTemplateProject/Main.cmake @@ -3,7 +3,16 @@ # Includes QtSetup and friends for private CMake API. set(QT_INTERNAL_IS_STANDALONE_TEST TRUE) + +# Checks minimum CMake version and upgrades policies. qt_internal_project_setup() + +# Look for the Qt6 package before trying to call qt_build_internals_set_up_private_api, +# otherwise it will fail when using a cross-compiled Qt, because QT_HOST_PATH will not be set. +# QT_HOST_PATH is set by Qt6Dependencies.cmake. +find_package(Qt6 REQUIRED) + +# Includes QtSetup.cmake. qt_build_internals_set_up_private_api() # Find all StandaloneTestsConfig.cmake files, and include them