From 489ade90c67af411501ad35cee9587afac1531a2 Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Tue, 19 Jul 2022 18:37:04 +0200 Subject: CMake: Don't look for Qt6 components that are already found This matches what we do in Dependencies.cmake files, except this time for COMPONENTS passed to the Qt6 package. For example if a project does find_package(Qt6 COMPONENTS Widgets Core) we'd end up looking for Core twice. Once as a dependency of Widgets and once as a standalone request of the project. Make sure to skip the second lookup if it was already found. Task-number: QTBUG-104998 Change-Id: I61db7fbb99818b4b70a0bfe3e167b6f14732292e Reviewed-by: Alexey Edelev (cherry picked from commit 63db26a47ec49699026a4b8f0e128ecdad2570e4) Reviewed-by: Qt Cherry-pick Bot --- cmake/QtConfig.cmake.in | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'cmake') diff --git a/cmake/QtConfig.cmake.in b/cmake/QtConfig.cmake.in index b9cf5e0964..3b38eb037d 100644 --- a/cmake/QtConfig.cmake.in +++ b/cmake/QtConfig.cmake.in @@ -183,17 +183,19 @@ foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS}) _qt_internal_save_find_package_context_for_debugging(@INSTALL_CMAKE_NAMESPACE@${module}) - find_package(@INSTALL_CMAKE_NAMESPACE@${module} - ${@INSTALL_CMAKE_NAMESPACE@_FIND_VERSION} - ${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET} - PATHS - ${_qt_cmake_dir} - ${_qt_additional_packages_prefix_paths} - ${QT_EXAMPLES_CMAKE_PREFIX_PATH} - ${__qt_find_package_host_qt_path} - ${_qt_additional_host_packages_prefix_paths} - ${__qt_use_no_default_path_for_qt_packages} - ) + if(NOT @INSTALL_CMAKE_NAMESPACE@${module}_FOUND) + find_package(@INSTALL_CMAKE_NAMESPACE@${module} + ${@INSTALL_CMAKE_NAMESPACE@_FIND_VERSION} + ${_@INSTALL_CMAKE_NAMESPACE@_FIND_PARTS_QUIET} + PATHS + ${_qt_cmake_dir} + ${_qt_additional_packages_prefix_paths} + ${QT_EXAMPLES_CMAKE_PREFIX_PATH} + ${__qt_find_package_host_qt_path} + ${_qt_additional_host_packages_prefix_paths} + ${__qt_use_no_default_path_for_qt_packages} + ) + endif() if(NOT "${__qt_find_package_host_qt_path}" STREQUAL "") set(CMAKE_PREFIX_PATH "${__qt_backup_cmake_prefix_path}") -- cgit v1.2.3