Skip to content

Commit

Permalink
CMake: Allow enabling/disabling QT_HOST_PATH checks via variable
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Craig Scott <[email protected]>
  • Loading branch information
alcroito committed Oct 29, 2021
1 parent f917df2 commit b04a0f0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmake/qt.toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit b04a0f0

Please sign in to comment.