From f04dbdfc97f88260f312da325efd60170450671a Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Mon, 1 Nov 2021 10:41:11 +0100 Subject: CMake: Don't create targets if dependencies are not found If one of the dependencies in QtFooModuleDependencies.cmake is not found, QtFoo_FOUND will be set to False by find_dependency. In that case, we should not create imported targets that belong to that package. It would be misleading for projects that do target existence checks instead of package_FOUND checks as well as generally being incorrect. The created imported targets might be referencing other targets that would not exist. Pick-to: 6.2 Fixes: QTBUG-97896 Change-Id: I09198aa3f19be047b27c29329b6e62c30fa09dc0 Reviewed-by: Qt CI Bot Reviewed-by: Craig Scott --- cmake/QtModuleConfig.cmake.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'cmake/QtModuleConfig.cmake.in') diff --git a/cmake/QtModuleConfig.cmake.in b/cmake/QtModuleConfig.cmake.in index 76fde2dc1f..76c918a774 100644 --- a/cmake/QtModuleConfig.cmake.in +++ b/cmake/QtModuleConfig.cmake.in @@ -22,7 +22,7 @@ if(NOT DEFINED "@INSTALL_CMAKE_NAMESPACE@@target@_FOUND") set("@INSTALL_CMAKE_NAMESPACE@@target@_FOUND" TRUE) endif() -if (NOT QT_NO_CREATE_TARGETS) +if (NOT QT_NO_CREATE_TARGETS AND @INSTALL_CMAKE_NAMESPACE@@target@_FOUND) include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@Targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@@target@AdditionalTargetInfo.cmake") if(NOT QT_NO_CREATE_VERSIONLESS_TARGETS) -- cgit v1.2.3