CMake: Move Qt6HostInfo lookup into a function

Also replace the duplicate call in QtSetup using the
new function.
To do that, we have to actually the call it in QtBuild
after QtPublicDependencyHelpers.cmake is available.

That call is needed so that Qt6_HOST_INFO_foo variables
are available in qt_generate_qmake_and_qtpaths_wrapper_for_target.

Task-number: QTBUG-104998
Change-Id: Ic5776c214bee6bedcea714b213b0e5a42c1bae06
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
(cherry picked from commit a41bef8edeffe7b77970968533793a587215d977)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Alexandru Croitor 2022-07-15 18:14:20 +02:00 committed by Qt Cherry-pick Bot
parent f42eb2aabc
commit e14e134d86
5 changed files with 24 additions and 27 deletions

View File

@ -552,6 +552,14 @@ include(QtPublicFindPackageHelpers)
include(QtPublicDependencyHelpers) include(QtPublicDependencyHelpers)
include(QtPublicToolHelpers) include(QtPublicToolHelpers)
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()
endif()
_qt_internal_find_host_info_package()
# TODO: This block provides support for old variables. It should be removed once # TODO: This block provides support for old variables. It should be removed once
# we remove all references to these variables in other Qt module repos. # we remove all references to these variables in other Qt module repos.
# Prefer to use the provided commands to retrieve the relevant things instead. # Prefer to use the provided commands to retrieve the relevant things instead.

View File

@ -23,16 +23,6 @@ else()
QT_VERSION_PATCH @PROJECT_VERSION_PATCH@) QT_VERSION_PATCH @PROJECT_VERSION_PATCH@)
endif() endif()
if(NOT "${QT_HOST_PATH}" STREQUAL "")
find_package(Qt@PROJECT_VERSION_MAJOR@HostInfo
CONFIG
REQUIRED
PATHS "${QT_HOST_PATH}"
"${QT_HOST_PATH_CMAKE_DIR}"
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
endif()
get_filename_component(_qt_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH) get_filename_component(_qt_import_prefix "${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_qt_import_prefix "${_qt_import_prefix}" REALPATH) get_filename_component(_qt_import_prefix "${_qt_import_prefix}" REALPATH)
list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}") list(APPEND CMAKE_MODULE_PATH "${_qt_import_prefix}")

View File

@ -1,5 +1,7 @@
set(@INSTALL_CMAKE_NAMESPACE@_FOUND FALSE) set(@INSTALL_CMAKE_NAMESPACE@_FOUND FALSE)
_qt_internal_find_host_info_package()
# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;" # note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;"
set(__qt_third_party_deps "@third_party_deps@") set(__qt_third_party_deps "@third_party_deps@")

View File

@ -191,3 +191,15 @@ macro(_qt_internal_save_find_package_context_for_debugging infix)
set(_qt_${infix}_qt_cmake_dir "${_qt_cmake_dir}") set(_qt_${infix}_qt_cmake_dir "${_qt_cmake_dir}")
endif() endif()
endmacro() endmacro()
macro(_qt_internal_find_host_info_package)
if(NOT "${QT_HOST_PATH}" STREQUAL "")
find_package(Qt6HostInfo
CONFIG
REQUIRED
PATHS "${QT_HOST_PATH}"
"${QT_HOST_PATH_CMAKE_DIR}"
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
endif()
endmacro()

View File

@ -254,26 +254,11 @@ unset(_qt_build_examples_as_external)
option(QT_BUILD_MANUAL_TESTS "Build Qt manual tests" OFF) 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): ## Path used to find host tools, either when cross-compiling or just when using the tools from
## a different host build.
set(QT_HOST_PATH "$ENV{QT_HOST_PATH}" CACHE PATH set(QT_HOST_PATH "$ENV{QT_HOST_PATH}" CACHE PATH
"Installed Qt host directory path, used for cross compiling.") "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()
endif()
if(NOT "${QT_HOST_PATH}" STREQUAL "")
find_package(${INSTALL_CMAKE_NAMESPACE}HostInfo
CONFIG
REQUIRED
PATHS "${QT_HOST_PATH}"
"${QT_HOST_PATH_CMAKE_DIR}"
NO_CMAKE_FIND_ROOT_PATH
NO_DEFAULT_PATH)
endif()
## Android platform settings ## Android platform settings
if(ANDROID) if(ANDROID)
include(QtPlatformAndroid) include(QtPlatformAndroid)