path: root/cmake/
diff options
authorAlexandru Croitor <>2021-10-22 12:31:39 +0200
committerAlexandru Croitor <>2021-10-29 15:34:12 +0200
commitb04a0f0c04ae69ae9dd6fc48865be70d39752980 (patch)
treea6d28145d947c1027f6613c9bb58f3bffbc8fa09 /cmake/
parentf917df27520874e5645ac51a1f65aae4a2375ce5 (diff)
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 <>
Diffstat (limited to 'cmake/')
1 files changed, 7 insertions, 1 deletions
diff --git a/cmake/ b/cmake/
index 5e9acd66b8..b8c5852dff 100644
--- a/cmake/
+++ b/cmake/
@@ -5,6 +5,7 @@ set(__qt_toolchain_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.
+ set(__qt_toolchain_host_path_required "${QT_REQUIRE_HOST_PATH_CHECK}")
+ set(__qt_toolchain_host_path_required "@qt_host_path_required@")