CMake: Move QT_HOST_PATH check and computation into Qt6 package
Instead of trying to compute and validate the QT_HOST_PATH and QT_HOST_PATH_CMAKE_DIR variables in the generated toolchain file, do it in the Qt6 package. This provides better error messages when a project is configured without using the Qt generated toolchain file. Because it's not done in the toolchain anymore, remove the various host variables from __qt_toolchain_used_variables. Pick-to: 6.4 Task-number: QTBUG-104998 Change-Id: I1ca239ff83b8f783897e171fee352fc43e8ad7a8 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
parent
7b24ffa936
commit
0f8017efb6
@ -1,6 +1,13 @@
|
|||||||
set(@INSTALL_CMAKE_NAMESPACE@_FOUND FALSE)
|
set(@INSTALL_CMAKE_NAMESPACE@_FOUND FALSE)
|
||||||
|
|
||||||
set(__qt_platform_requires_host_info_package "@platform_requires_host_info_package@")
|
set(__qt_platform_requires_host_info_package "@platform_requires_host_info_package@")
|
||||||
|
set(__qt_platform_initial_qt_host_path "@qt_host_path_absolute@")
|
||||||
|
set(__qt_platform_initial_qt_host_path_cmake_dir "@qt_host_path_cmake_dir_absolute@")
|
||||||
|
|
||||||
|
_qt_internal_setup_qt_host_path(
|
||||||
|
"${__qt_platform_requires_host_info_package}"
|
||||||
|
"${__qt_platform_initial_qt_host_path}"
|
||||||
|
"${__qt_platform_initial_qt_host_path_cmake_dir}")
|
||||||
_qt_internal_find_host_info_package(${__qt_platform_requires_host_info_package})
|
_qt_internal_find_host_info_package(${__qt_platform_requires_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\\;\\;"
|
||||||
|
@ -371,6 +371,14 @@ endif()")
|
|||||||
|
|
||||||
_qt_internal_determine_if_host_info_package_needed(platform_requires_host_info_package)
|
_qt_internal_determine_if_host_info_package_needed(platform_requires_host_info_package)
|
||||||
|
|
||||||
|
if(platform_requires_host_info_package)
|
||||||
|
# TODO: Figure out how to make the initial QT_HOST_PATH var relocatable in relation
|
||||||
|
# to the target CMAKE_INSTALL_DIR, if at all possible to do so in a reliable way.
|
||||||
|
get_filename_component(qt_host_path_absolute "${QT_HOST_PATH}" ABSOLUTE)
|
||||||
|
get_filename_component(qt_host_path_cmake_dir_absolute
|
||||||
|
"${Qt${PROJECT_VERSION_MAJOR}HostInfo_DIR}/.." ABSOLUTE)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(third_party_deps OR platform_requires_host_info_package)
|
if(third_party_deps OR platform_requires_host_info_package)
|
||||||
# Setup build and install paths.
|
# Setup build and install paths.
|
||||||
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}")
|
set(path_suffix "${INSTALL_CMAKE_NAMESPACE}")
|
||||||
|
@ -194,7 +194,11 @@ endmacro()
|
|||||||
|
|
||||||
function(_qt_internal_determine_if_host_info_package_needed out_var)
|
function(_qt_internal_determine_if_host_info_package_needed out_var)
|
||||||
set(needed FALSE)
|
set(needed FALSE)
|
||||||
if(NOT "${QT_HOST_PATH}" STREQUAL "")
|
|
||||||
|
# If a QT_HOST_PATH is provided when configuring qtbase, we assume it's a cross build
|
||||||
|
# and thus we require the QT_HOST_PATH to be provided also when using the cross-built Qt.
|
||||||
|
# This tells the QtConfigDependencies file to do appropriate requirement checks.
|
||||||
|
if(NOT "${QT_HOST_PATH}" STREQUAL "" AND NOT QT_NO_REQUIRE_HOST_PATH_CHECK)
|
||||||
set(needed TRUE)
|
set(needed TRUE)
|
||||||
endif()
|
endif()
|
||||||
set(${out_var} "${needed}" PARENT_SCOPE)
|
set(${out_var} "${needed}" PARENT_SCOPE)
|
||||||
@ -211,3 +215,73 @@ macro(_qt_internal_find_host_info_package platform_requires_host_info)
|
|||||||
NO_DEFAULT_PATH)
|
NO_DEFAULT_PATH)
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
|
macro(_qt_internal_setup_qt_host_path
|
||||||
|
host_path_required
|
||||||
|
initial_qt_host_path
|
||||||
|
initial_qt_host_path_cmake_dir
|
||||||
|
)
|
||||||
|
# Set up QT_HOST_PATH and do sanity checks.
|
||||||
|
# A host path is required when cross-compiling but optional when doing a native build.
|
||||||
|
# Requiredness can be overridden via variable.
|
||||||
|
if(DEFINED QT_REQUIRE_HOST_PATH_CHECK)
|
||||||
|
set(_qt_platform_host_path_required "${QT_REQUIRE_HOST_PATH_CHECK}")
|
||||||
|
else()
|
||||||
|
set(_qt_platform_host_path_required "${host_path_required}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(_qt_platform_host_path_required)
|
||||||
|
# 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 "")
|
||||||
|
elseif(NOT "${initial_qt_host_path}" STREQUAL "" AND EXISTS "${initial_qt_host_path}")
|
||||||
|
set(QT_HOST_PATH "${initial_qt_host_path}" CACHE PATH "")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT QT_HOST_PATH STREQUAL "")
|
||||||
|
get_filename_component(_qt_platform_host_path_absolute "${QT_HOST_PATH}" ABSOLUTE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${QT_HOST_PATH}" STREQUAL "" OR NOT EXISTS "${_qt_platform_host_path_absolute}")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"To use a cross-compiled Qt, please set the QT_HOST_PATH cache variable to the "
|
||||||
|
"location of your host Qt installation.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# QT_HOST_PATH_CMAKE_DIR is needed to work around the rerooting issue when looking for host
|
||||||
|
# tools. See REROOT_PATH_ISSUE_MARKER.
|
||||||
|
# Prefer initially configured path if none was explicitly set.
|
||||||
|
if(NOT DEFINED QT_HOST_PATH_CMAKE_DIR)
|
||||||
|
if(NOT "${initial_qt_host_path_cmake_dir}" STREQUAL ""
|
||||||
|
AND EXISTS "${initial_qt_host_path_cmake_dir}")
|
||||||
|
set(QT_HOST_PATH_CMAKE_DIR "${initial_qt_host_path_cmake_dir}" CACHE PATH "")
|
||||||
|
else()
|
||||||
|
# First try to auto-compute the location instead of requiring to set
|
||||||
|
# QT_HOST_PATH_CMAKE_DIR explicitly.
|
||||||
|
set(__qt_candidate_host_path_cmake_dir "${QT_HOST_PATH}/lib/cmake")
|
||||||
|
if(__qt_candidate_host_path_cmake_dir
|
||||||
|
AND EXISTS "${__qt_candidate_host_path_cmake_dir}")
|
||||||
|
set(QT_HOST_PATH_CMAKE_DIR
|
||||||
|
"${__qt_candidate_host_path_cmake_dir}" CACHE PATH "")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT QT_HOST_PATH_CMAKE_DIR STREQUAL "")
|
||||||
|
get_filename_component(_qt_platform_host_path_cmake_dir_absolute
|
||||||
|
"${QT_HOST_PATH_CMAKE_DIR}" ABSOLUTE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if("${QT_HOST_PATH_CMAKE_DIR}" STREQUAL ""
|
||||||
|
OR NOT EXISTS "${_qt_platform_host_path_cmake_dir_absolute}")
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"To use a cross-compiled Qt, please set the QT_HOST_PATH_CMAKE_DIR cache variable "
|
||||||
|
"to the location of your host Qt installation lib/cmake directory.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
@ -2,21 +2,6 @@
|
|||||||
# as well as CMake application projects.
|
# as well as CMake application projects.
|
||||||
# Expects various global variables to be set.
|
# Expects various global variables to be set.
|
||||||
function(qt_internal_create_toolchain_file)
|
function(qt_internal_create_toolchain_file)
|
||||||
set(qt_host_path_required FALSE)
|
|
||||||
|
|
||||||
if(NOT "${QT_HOST_PATH}" STREQUAL "")
|
|
||||||
# If a QT_HOST_PATH is provided when configuring qtbase, we assume it's a cross build
|
|
||||||
# and thus we require the QT_HOST_PATH to be provided also when using the cross-built Qt.
|
|
||||||
# This tells the Qt toolchain file to do appropriate requirement checks.
|
|
||||||
set(qt_host_path_required TRUE)
|
|
||||||
|
|
||||||
# TODO: Figure out how to make the initial QT_HOST_PATH var relocatable in relation
|
|
||||||
# to the target CMAKE_INSTALL_DIR, if at all possible to do so in a reliable way.
|
|
||||||
get_filename_component(qt_host_path_absolute "${QT_HOST_PATH}" ABSOLUTE)
|
|
||||||
get_filename_component(qt_host_path_cmake_dir_absolute
|
|
||||||
"${Qt${PROJECT_VERSION_MAJOR}HostInfo_DIR}/.." ABSOLUTE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_TOOLCHAIN_FILE)
|
if(CMAKE_TOOLCHAIN_FILE)
|
||||||
file(TO_CMAKE_PATH "${CMAKE_TOOLCHAIN_FILE}" __qt_chainload_toolchain_file)
|
file(TO_CMAKE_PATH "${CMAKE_TOOLCHAIN_FILE}" __qt_chainload_toolchain_file)
|
||||||
set(init_original_toolchain_file
|
set(init_original_toolchain_file
|
||||||
|
@ -3,11 +3,7 @@ set(__qt_toolchain_used_variables
|
|||||||
QT_TOOLCHAIN_INCLUDE_FILE
|
QT_TOOLCHAIN_INCLUDE_FILE
|
||||||
QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR
|
QT_TOOLCHAIN_RELOCATABLE_CMAKE_DIR
|
||||||
QT_TOOLCHAIN_RELOCATABLE_PREFIX
|
QT_TOOLCHAIN_RELOCATABLE_PREFIX
|
||||||
QT_HOST_PATH
|
|
||||||
QT_HOST_PATH_CMAKE_DIR
|
|
||||||
QT_REQUIRE_HOST_PATH_CHECK
|
|
||||||
QT_ADDITIONAL_PACKAGES_PREFIX_PATH
|
QT_ADDITIONAL_PACKAGES_PREFIX_PATH
|
||||||
QT_ADDITIONAL_HOST_PACKAGES_PREFIX_PATH
|
|
||||||
)
|
)
|
||||||
@init_additional_used_variables@
|
@init_additional_used_variables@
|
||||||
|
|
||||||
@ -154,73 +150,6 @@ if(QT_TOOLCHAIN_INCLUDE_FILE)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
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.
|
|
||||||
# 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
|
|
||||||
"@qt_host_path_cmake_dir_absolute@")
|
|
||||||
|
|
||||||
# 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 "")
|
|
||||||
get_filename_component(__qt_toolchain_host_path_absolute "${QT_HOST_PATH}" ABSOLUTE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(__qt_toolchain_host_path_required AND
|
|
||||||
("${QT_HOST_PATH}" STREQUAL "" OR NOT EXISTS "${__qt_toolchain_host_path_absolute}"))
|
|
||||||
message(FATAL_ERROR
|
|
||||||
"To use a cross-compiled Qt, please set the QT_HOST_PATH cache variable to the location "
|
|
||||||
"of your host Qt installation.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# QT_HOST_PATH_CMAKE_DIR is needed to work around the rerooting issue when looking for host tools
|
|
||||||
# See REROOT_PATH_ISSUE_MARKER.
|
|
||||||
# Prefer initially configured path if none was explicitly set.
|
|
||||||
if(__qt_toolchain_host_path_required AND NOT DEFINED QT_HOST_PATH_CMAKE_DIR)
|
|
||||||
if(__qt_toolchain_initial_qt_host_path_cmake_dir
|
|
||||||
AND EXISTS "${__qt_toolchain_initial_qt_host_path_cmake_dir}")
|
|
||||||
set(QT_HOST_PATH_CMAKE_DIR "${__qt_toolchain_initial_qt_host_path_cmake_dir}" CACHE PATH "")
|
|
||||||
else()
|
|
||||||
# First try to auto-compute the location instead of requiring to set QT_HOST_PATH_CMAKE_DIR
|
|
||||||
# explicitly.
|
|
||||||
set(__qt_candidate_host_path_cmake_dir "${QT_HOST_PATH}/lib/cmake")
|
|
||||||
if(__qt_candidate_host_path_cmake_dir AND EXISTS "${__qt_candidate_host_path_cmake_dir}")
|
|
||||||
set(QT_HOST_PATH_CMAKE_DIR
|
|
||||||
"${__qt_candidate_host_path_cmake_dir}" CACHE PATH "")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT QT_HOST_PATH_CMAKE_DIR STREQUAL "")
|
|
||||||
get_filename_component(__qt_toolchain_host_path_cmake_dir_absolute
|
|
||||||
"${QT_HOST_PATH_CMAKE_DIR}" ABSOLUTE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(__qt_toolchain_host_path_required AND
|
|
||||||
("${QT_HOST_PATH_CMAKE_DIR}" STREQUAL ""
|
|
||||||
OR NOT EXISTS "${__qt_toolchain_host_path_cmake_dir_absolute}"))
|
|
||||||
message(FATAL_ERROR
|
|
||||||
"To use a cross-compiled Qt, please set the QT_HOST_PATH_CMAKE_DIR cache variable to "
|
|
||||||
"the location of your host Qt installation lib/cmake directory.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Store initial build type (if any is specified) to be read by QtBuildInternals.cmake when building
|
# Store initial build type (if any is specified) to be read by QtBuildInternals.cmake when building
|
||||||
# a Qt repo, standalone tests or a single test.
|
# a Qt repo, standalone tests or a single test.
|
||||||
if(DEFINED CACHE{CMAKE_BUILD_TYPE})
|
if(DEFINED CACHE{CMAKE_BUILD_TYPE})
|
||||||
|
Loading…
Reference in New Issue
Block a user