diff options
author | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-07-18 14:14:41 +0200 |
---|---|---|
committer | Alexandru Croitor <alexandru.croitor@qt.io> | 2022-07-25 19:52:22 +0200 |
commit | 7b24ffa936880619f54c8cc1a459a0328238657c (patch) | |
tree | 1b1a2b8f6d9c7e84d1ab9b4d4a0ca7298f84b783 /cmake | |
parent | a41bef8edeffe7b77970968533793a587215d977 (diff) |
CMake: Improve Qt6HostInfo package lookup condition
Instead of checking if QT_HOST_PATH is set during user project
configuration to find out if Qt6HostInfo should be looked up,
record if QT_HOST_PATH was provided during Qt configuration
into Qt6Dependencies.cmake and look up the package in a user
project based on that information.
This improves handling of the case where cmake is directly used
to configure a Qt project (instead of qt-cmake), which means no
QT_HOST_PATH might be set by the user, and then cmake would error out
saying that e.g. Qt6CoreTools is not found, instead of saying that
Qt6HostInfo is not found.
Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I0377d5440e4b5b295af73cfd4b5188f61d48e440
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtBuild.cmake | 3 | ||||
-rw-r--r-- | cmake/QtConfigDependencies.cmake.in | 3 | ||||
-rw-r--r-- | cmake/QtPostProcessHelpers.cmake | 4 | ||||
-rw-r--r-- | cmake/QtPublicDependencyHelpers.cmake | 10 |
4 files changed, 16 insertions, 4 deletions
diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index d3d41dbd07..4b7cc643bb 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -558,7 +558,8 @@ if(CMAKE_CROSSCOMPILING) endif() endif() -_qt_internal_find_host_info_package() +_qt_internal_determine_if_host_info_package_needed(__qt_build_requires_host_info_package) +_qt_internal_find_host_info_package("${__qt_build_requires_host_info_package}") # 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. diff --git a/cmake/QtConfigDependencies.cmake.in b/cmake/QtConfigDependencies.cmake.in index aabfa90328..a369b9035f 100644 --- a/cmake/QtConfigDependencies.cmake.in +++ b/cmake/QtConfigDependencies.cmake.in @@ -1,6 +1,7 @@ set(@INSTALL_CMAKE_NAMESPACE@_FOUND FALSE) -_qt_internal_find_host_info_package() +set(__qt_platform_requires_host_info_package "@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\\;\\;" set(__qt_third_party_deps "@third_party_deps@") diff --git a/cmake/QtPostProcessHelpers.cmake b/cmake/QtPostProcessHelpers.cmake index d3f917af8d..5507f552de 100644 --- a/cmake/QtPostProcessHelpers.cmake +++ b/cmake/QtPostProcessHelpers.cmake @@ -369,7 +369,9 @@ function(qt_internal_create_qt6_dependencies_file) endif()") endif() - if(third_party_deps) + _qt_internal_determine_if_host_info_package_needed(platform_requires_host_info_package) + + if(third_party_deps OR platform_requires_host_info_package) # Setup build and install paths. set(path_suffix "${INSTALL_CMAKE_NAMESPACE}") diff --git a/cmake/QtPublicDependencyHelpers.cmake b/cmake/QtPublicDependencyHelpers.cmake index 5abd9cff38..2e3db75007 100644 --- a/cmake/QtPublicDependencyHelpers.cmake +++ b/cmake/QtPublicDependencyHelpers.cmake @@ -192,8 +192,16 @@ macro(_qt_internal_save_find_package_context_for_debugging infix) endif() endmacro() -macro(_qt_internal_find_host_info_package) +function(_qt_internal_determine_if_host_info_package_needed out_var) + set(needed FALSE) if(NOT "${QT_HOST_PATH}" STREQUAL "") + set(needed TRUE) + endif() + set(${out_var} "${needed}" PARENT_SCOPE) +endfunction() + +macro(_qt_internal_find_host_info_package platform_requires_host_info) + if(${platform_requires_host_info}) find_package(Qt6HostInfo CONFIG REQUIRED |