From b04a0f0c04ae69ae9dd6fc48865be70d39752980 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 22 Oct 2021 12:31:39 +0200 Subject: CMake: Allow enabling/disabling QT_HOST_PATH checks via variable One can now pass -DQT_REQUIRE_HOST_PATH_CHECK=OFF or -DQT_REQUIRE_HOST_PATH_CHECK=ON to force disable or enable the QT_HOST_PATH and QT_HOST_CMAKE_DIR_PATH validity checks. One potential use case is if a project wants to manually find QtFooTools packages by manipulating CMAKE_FIND_ROOT_PATH and such, in which case they might not want to pass a QT_HOST_PATH. Another potential use case is cross-building Qt with -DQT_BUILD_TOOLS_WHEN_CROSSCOMPILING=ON and allowing the same generated toolchain file to be used on the device image. By default the generated toolchain file would require a host path because it expects that it's still being used for cross-compiling. But once the toolchain file is deployed to the device there's no need to use the host tools anymore. Another use case is building a desktop Qt using the host tools of another desktop Qt. The new desktop Qt can use its newly built tools just fine and wouldn't need the original desktop Qt tools. QT_REQUIRE_HOST_PATH_CHECK needs to be added the list of vars to pass through to try_compile calls. Change-Id: I4b922b5d854828e6b9210dd8c07b4b1b8630aad1 Reviewed-by: Qt CI Bot Reviewed-by: Craig Scott --- cmake/qt.toolchain.cmake.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'cmake/qt.toolchain.cmake.in') diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in index 5e9acd66b8..b8c5852dff 100644 --- a/cmake/qt.toolchain.cmake.in +++ b/cmake/qt.toolchain.cmake.in @@ -5,6 +5,7 @@ set(__qt_toolchain_used_variables QT_TOOLCHAIN_RELOCATABLE_PREFIX QT_HOST_PATH QT_HOST_PATH_CMAKE_DIR + QT_REQUIRE_HOST_PATH_CHECK ) @init_additional_used_variables@ @@ -142,7 +143,12 @@ endif() # Set up QT_HOST_PATH and do sanity checks. # A host path is required when cross-compiling but optional when doing a native build. -set(__qt_toolchain_host_path_required "@qt_host_path_required@") +# Requiredness can be overridden via variable. +if(DEFINED QT_REQUIRE_HOST_PATH_CHECK) + set(__qt_toolchain_host_path_required "${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 -- cgit v1.2.3