summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmake/QtSetup.cmake3
-rw-r--r--cmake/qt.toolchain.cmake.in14
2 files changed, 12 insertions, 5 deletions
diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake
index 7db9612cd9..87d3ad9cf8 100644
--- a/cmake/QtSetup.cmake
+++ b/cmake/QtSetup.cmake
@@ -217,7 +217,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)
## 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(NOT IS_DIRECTORY "${QT_HOST_PATH}")
diff --git a/cmake/qt.toolchain.cmake.in b/cmake/qt.toolchain.cmake.in
index 9054e9c4ef..6e37ae0281 100644
--- a/cmake/qt.toolchain.cmake.in
+++ b/cmake/qt.toolchain.cmake.in
@@ -167,10 +167,16 @@ set(__qt_toolchain_initial_qt_host_path
set(__qt_toolchain_initial_qt_host_path_cmake_dir
"@qt_host_path_cmake_dir_absolute@")
-# Prefer initially configured path if none was explicitly set.
-if(NOT DEFINED QT_HOST_PATH AND __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 "")
+# QT_HOST_PATH precedence:
+# - cache variable / command line option
+# - environment variable
+# - 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()
if(NOT QT_HOST_PATH STREQUAL "")