CMake: Read QT_HOST_PATH from the environment too

For cross-compiled conan packages we need conan to export QT_HOST_PATH
as an environment variable.  The Qt build now picks up this environment
variable if no QT_HOST_PATH cache variable was specified.

Change-Id: I0c3e15e82842061d5db81949ffcc1c240f6ed6a4
Reviewed-by: Iikka Eklund <iikka.eklund@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit 599c648b77628fe195e78d6e7ac145f258f8880b)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Joerg Bornemann 2022-02-24 11:44:11 +01:00
parent a7a9622d73
commit 355a6f41fa
2 changed files with 12 additions and 5 deletions

View File

@ -241,7 +241,8 @@ option(QT_BUILD_MANUAL_TESTS "Build Qt manual tests" OFF)
option(QT_BUILD_MINIMAL_STATIC_TESTS "Build minimal subset of tests for static Qt builds" OFF) option(QT_BUILD_MINIMAL_STATIC_TESTS "Build minimal subset of tests for static Qt builds" OFF)
## Find host tools (if non native): ## Find host tools (if non native):
set(QT_HOST_PATH "" CACHE PATH "Installed Qt host directory path, used for cross compiling.") set(QT_HOST_PATH "$ENV{QT_HOST_PATH}" CACHE PATH
"Installed Qt host directory path, used for cross compiling.")
if (CMAKE_CROSSCOMPILING) if (CMAKE_CROSSCOMPILING)
if(NOT IS_DIRECTORY "${QT_HOST_PATH}") if(NOT IS_DIRECTORY "${QT_HOST_PATH}")

View File

@ -161,10 +161,16 @@ set(__qt_toolchain_initial_qt_host_path
set(__qt_toolchain_initial_qt_host_path_cmake_dir set(__qt_toolchain_initial_qt_host_path_cmake_dir
"@qt_host_path_cmake_dir_absolute@") "@qt_host_path_cmake_dir_absolute@")
# Prefer initially configured path if none was explicitly set. # QT_HOST_PATH precedence:
if(NOT DEFINED QT_HOST_PATH AND __qt_toolchain_initial_qt_host_path # - cache variable / command line option
AND EXISTS "${__qt_toolchain_initial_qt_host_path}") # - environment variable
set(QT_HOST_PATH "${__qt_toolchain_initial_qt_host_path}" CACHE PATH "") # - initial QT_HOST_PATH when qtbase was configured (and the directory exists)
if(NOT DEFINED QT_HOST_PATH)
if(DEFINED ENV{QT_HOST_PATH})
set(QT_HOST_PATH "$ENV{QT_HOST_PATH}" CACHE PATH "")
else(__qt_toolchain_initial_qt_host_path AND EXISTS "${__qt_toolchain_initial_qt_host_path}")
set(QT_HOST_PATH "${__qt_toolchain_initial_qt_host_path}" CACHE PATH "")
endif()
endif() endif()
if(NOT QT_HOST_PATH STREQUAL "") if(NOT QT_HOST_PATH STREQUAL "")