CMake: Don't repeatedly look for the Qt6 dependency

When loading Qt packages, don't look for the Qt6 dependency if it was
already found in the given subdirectory scope.

This reduces the amount of find_dependency(Qt6) calls.

Pick-to: 6.4
Task-number: QTBUG-104998
Change-Id: I737c4433daf30eed51a058b45cd539dff7657ca4
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2022-07-18 16:53:23 +02:00
parent 0f8017efb6
commit 8dac271889

View File

@ -13,14 +13,17 @@ endif()
# set _NOT_FOUND_MESSAGE which will be displayed by the includer of the Dependencies file.
set(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED FALSE)
find_dependency(@INSTALL_CMAKE_NAMESPACE@ @main_qt_package_version@
PATHS
"${CMAKE_CURRENT_LIST_DIR}/.."
"${_qt_cmake_dir}"
${_qt_additional_packages_prefix_paths}
${QT_EXAMPLES_CMAKE_PREFIX_PATH}
${__qt_use_no_default_path_for_qt_packages}
)
if(NOT @INSTALL_CMAKE_NAMESPACE@_FOUND)
find_dependency(@INSTALL_CMAKE_NAMESPACE@ @main_qt_package_version@
PATHS
"${CMAKE_CURRENT_LIST_DIR}/.."
"${_qt_cmake_dir}"
${_qt_additional_packages_prefix_paths}
${QT_EXAMPLES_CMAKE_PREFIX_PATH}
${__qt_use_no_default_path_for_qt_packages}
)
endif()
# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;"
set(__qt_@target@_third_party_deps "@third_party_deps@")