From 34b1c1c23cbddf67f878579bee9d10dcac29d8ca Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Fri, 27 Sep 2019 13:29:47 +0200 Subject: [PATCH] Fix qt_find_package to not show incorrect packages at features summary qt_find_package usually does 2 find_package() calls, one in CONFIG mode and one in MODULE mode. If the CONFIG mode doesn't find a Config file, the package_DIR cache variable is set to NOTFOUND, and this causes the FeatureSummary at the end to show that the package was not found, even if it is found by the next MODULE mode find_package call. Make sure to unset the _DIR variable in case if the Config module call fails. This fixes XRender showing up as not found even when it's found via the FindXRender.cmake file. Change-Id: I6ce39dad9cbb11836ca71f735a3267070c75b444 Reviewed-by: Cristian Adam Reviewed-by: Albert Astals Cid Reviewed-by: Qt CMake Build Bot --- cmake/QtBuild.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/QtBuild.cmake b/cmake/QtBuild.cmake index f02553e8ea..5f64803508 100644 --- a/cmake/QtBuild.cmake +++ b/cmake/QtBuild.cmake @@ -2876,6 +2876,13 @@ macro(qt_find_package) endforeach() if (NOT ${ARGV0}_FOUND) + # Unset the NOTFOUND ${package}_DIR var that might have been set by the previous + # find_package call, to get rid of "not found" messagees in the feature summary + # if the package is found by the next find_package call. + if(DEFINED CACHE{${ARGV0}_DIR} AND NOT ${ARGV0}_DIR) + unset(${ARGV0}_DIR CACHE) + endif() + # Call original function without our custom arguments. find_package(${arg_UNPARSED_ARGUMENTS}) endif()