summaryrefslogtreecommitdiffstats
path: root/cmake/QtSetup.cmake
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2020-06-18 10:07:22 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2020-06-29 12:47:34 +0200
commitd7fd6848612760124871f0f3b55917250d078dd5 (patch)
tree49f97ad5f16f5fd32cf69a5497c20581bf65b592 /cmake/QtSetup.cmake
parentb0f9c06a9b199a7474eb94a6292b5824364344b6 (diff)
CMake: Support cross-compilation with qmake
When cross-compiling, we now create a target_qt.conf file that's to be used with the host Qt's qmake. With "qmake -qtconf .../target_qt.conf" projects can be cross-built against the cross-built Qt. We also create wrapper scripts for the host qmake to save the user from passing the -qtconf argument. Fixes: QTBUG-82581 Change-Id: Ib5866e7e820369efea9eb3171e3e3e3ca5c0c3c1 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtSetup.cmake')
-rw-r--r--cmake/QtSetup.cmake21
1 files changed, 14 insertions, 7 deletions
diff --git a/cmake/QtSetup.cmake b/cmake/QtSetup.cmake
index 4bed289453..b23b9924e0 100644
--- a/cmake/QtSetup.cmake
+++ b/cmake/QtSetup.cmake
@@ -152,6 +152,20 @@ option(QT_NO_MAKE_EXAMPLES "Should examples be built as part of the default 'all
# Build Benchmarks
option(QT_BUILD_BENCHMARKS "Build Qt Benchmarks" ${__build_benchmarks})
+## Find host tools (if non native):
+set(QT_HOST_PATH "" CACHE PATH "Installed Qt host directory path, used for cross compiling.")
+
+if (CMAKE_CROSSCOMPILING)
+ if(NOT IS_DIRECTORY ${QT_HOST_PATH})
+ message(FATAL_ERROR "You need to set QT_HOST_PATH to cross compile Qt.")
+ endif()
+ list(PREPEND CMAKE_PREFIX_PATH "${QT_HOST_PATH}")
+ list(PREPEND CMAKE_FIND_ROOT_PATH "${QT_HOST_PATH}")
+ find_package(Qt${PROJECT_VERSION_MAJOR}HostInfo REQUIRED)
+ list(POP_FRONT CMAKE_PREFIX_PATH)
+ list(POP_FRONT CMAKE_FIND_ROOT_PATH)
+endif()
+
## Android platform settings
if(ANDROID)
include(QtPlatformAndroid)
@@ -175,13 +189,6 @@ qt_set_up_nonprefix_build()
qt_set_language_standards()
-## Find host tools (if non native):
-set(QT_HOST_PATH "" CACHE PATH "Installed Qt host directory path, used for cross compiling.")
-
-if (CMAKE_CROSSCOMPILING AND NOT IS_DIRECTORY ${QT_HOST_PATH})
- message(FATAL_ERROR "You need to set QT_HOST_PATH to cross compile Qt.")
-endif()
-
## Enable support for sanitizers:
qt_internal_set_up_sanitizer_features()
include(${CMAKE_CURRENT_LIST_DIR}/3rdparty/extra-cmake-modules/modules/ECMEnableSanitizers.cmake)