From 3ff7cbaca3840f7a4cd269d4b93a171ac81c50ed Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 13 Jul 2022 18:11:54 +0200 Subject: [PATCH] CMake: Don't search for next Qt component if a required one is missing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a project calls find_package(Qt6 COMPONENTS Gui Network) and Gui is not found, there's no reason to look for Network, because the COMPONENTS option implies that it is a required component. Failing to find a component sets Qt6_FOUND to false, so we can break early. If a project calls find_package(Qt6 OPTIONAL_COMPONENTS Gui Network) then Network will still be looked for if Gui is not found. Task-number: QTBUG-104998 Change-Id: I5c5edd27729635e6b7ade059656b49320364ad13 Reviewed-by: Jörg Bornemann (cherry picked from commit ecfc0df9b2011a458ae4622b53b4fa6aec37b2a9) Reviewed-by: Qt Cherry-pick Bot --- cmake/QtConfig.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/QtConfig.cmake.in b/cmake/QtConfig.cmake.in index 9f8c80a2e53..2f0b8e0c0c3 100644 --- a/cmake/QtConfig.cmake.in +++ b/cmake/QtConfig.cmake.in @@ -236,6 +236,7 @@ foreach(module ${@INSTALL_CMAKE_NAMESPACE@_FIND_COMPONENTS}) if(@INSTALL_CMAKE_NAMESPACE@_FIND_REQUIRED_${module}) set(_Qt_NOTFOUND_MESSAGE "${_Qt_NOTFOUND_MESSAGE}Failed to find Qt component \"${module}\". ${_qt_component_not_found_msg}") + break() elseif(NOT @INSTALL_CMAKE_NAMESPACE@_FIND_QUIETLY) message(WARNING "Failed to find Qt component \"${module}\". ${_qt_component_not_found_msg}")