diff --git a/cmake/QtConfig.cmake.in b/cmake/QtConfig.cmake.in index b434665650..46a5d11ff7 100644 --- a/cmake/QtConfig.cmake.in +++ b/cmake/QtConfig.cmake.in @@ -51,7 +51,7 @@ endif() # Find required dependencies, if any. include(CMakeFindDependencyMacro) -set(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCIES_FOUND FALSE) +set(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCIES_FOUND TRUE) if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Dependencies.cmake") include("${CMAKE_CURRENT_LIST_DIR}/@INSTALL_CMAKE_NAMESPACE@Dependencies.cmake") endif() diff --git a/cmake/QtConfigDependencies.cmake.in b/cmake/QtConfigDependencies.cmake.in index e16d725928..301d808d8c 100644 --- a/cmake/QtConfigDependencies.cmake.in +++ b/cmake/QtConfigDependencies.cmake.in @@ -12,24 +12,24 @@ foreach(_target_dep ${_third_party_deps}) list(APPEND find_package_args "${version}") endif() - # Already build an error message, because find_dependency calls return() on failure. - set(__@INSTALL_CMAKE_NAMESPACE@_message "\nPackage: ${pkg}") - if(version) - string(APPEND __@INSTALL_CMAKE_NAMESPACE@_message "\nVersion: ${version}") - endif() - if(components) - string(APPEND __@INSTALL_CMAKE_NAMESPACE@_message "\nComponents: ${components}") - endif() - set(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCY_NOT_FOUND_MESSAGE - "${__@INSTALL_CMAKE_NAMESPACE@_message}") - if(components) string(REPLACE " " ";" components "${components}") find_dependency(${find_package_args} COMPONENTS ${components}) else() find_dependency(${find_package_args}) endif() -endforeach() -set(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCIES_FOUND TRUE) -unset(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCY_NOT_FOUND_MESSAGE) + if (NOT ${pkg}_FOUND) + set(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCIES_FOUND FALSE) + set(__@INSTALL_CMAKE_NAMESPACE@_message "\nPackage: ${pkg}") + if(version) + string(APPEND __@INSTALL_CMAKE_NAMESPACE@_message "\nVersion: ${version}") + endif() + if(components) + string(APPEND __@INSTALL_CMAKE_NAMESPACE@_message "\nComponents: ${components}") + endif() + set(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCY_NOT_FOUND_MESSAGE + "${__@INSTALL_CMAKE_NAMESPACE@_message}") + return() + endif() +endforeach() diff --git a/cmake/QtModuleDependencies.cmake.in b/cmake/QtModuleDependencies.cmake.in index 80c5202c9a..d598571d64 100644 --- a/cmake/QtModuleDependencies.cmake.in +++ b/cmake/QtModuleDependencies.cmake.in @@ -1,8 +1,11 @@ # Make sure @INSTALL_CMAKE_NAMESPACE@ is found before anything else. -set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE) find_dependency(@INSTALL_CMAKE_NAMESPACE@ @PROJECT_VERSION@ PATHS "${CMAKE_CURRENT_LIST_DIR}/.." ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH ) +if (NOT @INSTALL_CMAKE_NAMESPACE@_FOUND) + set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE) + return() +endif() # note: _third_party_deps example: "ICU\\;1.0\\;i18n uc data;ZLIB\\;\\;" set(_third_party_deps "@third_party_deps@") @@ -22,6 +25,11 @@ foreach(_target_dep ${_third_party_deps}) else() find_dependency(${find_package_args}) endif() + + if (NOT ${pkg}_FOUND) + set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE) + return() + endif() endforeach() # Find Qt tool package. @@ -39,15 +47,10 @@ foreach(_target_dep ${_tool_deps}) list(GET _target_dep 0 pkg) list(GET _target_dep 1 version) - unset(find_package_args) - if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) - list(APPEND find_package_args QUIET) - endif() - if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) - list(APPEND find_package_args REQUIRED) - endif() - find_package(${pkg} ${version} ${find_package_args}) + find_dependency(${pkg} ${version}) + if (NOT ${pkg}_FOUND) + set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE) if(QT_HOST_PATH) set(CMAKE_PREFIX_PATH ${BACKUP_@target@_CMAKE_PREFIX_PATH}) set(CMAKE_FIND_ROOT_PATH ${BACKUP_@target@_CMAKE_FIND_ROOT_PATH}) @@ -71,7 +74,12 @@ foreach(_target_dep ${_target_deps}) PATHS "${CMAKE_CURRENT_LIST_DIR}/.." ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH ) endif() + + if (NOT ${pkg}_FOUND) + set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE) + return() + endif() endforeach() set(_@QT_CMAKE_EXPORT_NAMESPACE@@target@_MODULE_DEPENDENCIES "@qt_module_dependencies@") -set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND TRUE) + diff --git a/cmake/QtModuleToolsDependencies.cmake.in b/cmake/QtModuleToolsDependencies.cmake.in index d9ff04b6f9..46c60b8484 100644 --- a/cmake/QtModuleToolsDependencies.cmake.in +++ b/cmake/QtModuleToolsDependencies.cmake.in @@ -1,5 +1,4 @@ # Find "ModuleTools" dependencies, which are other ModuleTools packages. -set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE) set(_tool_deps "@package_deps@") foreach(_target_dep ${_tool_deps}) list(GET _target_dep 0 pkg) @@ -8,6 +7,10 @@ foreach(_target_dep ${_tool_deps}) if (NOT ${pkg}_FOUND) find_dependency(${pkg} ${version}) endif() + + if (NOT ${pkg}_FOUND) + set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND FALSE) + return() + endif() endforeach() -set(@INSTALL_CMAKE_NAMESPACE@@target@_FOUND TRUE) diff --git a/cmake/QtPluginDependencies.cmake.in b/cmake/QtPluginDependencies.cmake.in index ce64b096bb..eb1d9c3433 100644 --- a/cmake/QtPluginDependencies.cmake.in +++ b/cmake/QtPluginDependencies.cmake.in @@ -1,5 +1,3 @@ -set(@target@_FOUND FALSE) - # note: _third_party_deps example: "ICU\\;1.0\\;i18n uc data;ZLIB\\;\\;" set(_third_party_deps "@third_party_deps@") @@ -12,11 +10,16 @@ foreach(_target_dep ${_third_party_deps}) list(APPEND find_package_args "${version}") endif() - if(components) - string(REPLACE " " ";" components "${components}") - find_dependency(${find_package_args} COMPONENTS ${components}) - else() - find_dependency(${find_package_args}) + if(components) + string(REPLACE " " ";" components "${components}") + find_dependency(${find_package_args} COMPONENTS ${components}) + else() + find_dependency(${find_package_args}) + endif() + + if (NOT ${pkg}_FOUND) + set(@target@_FOUND FALSE) + return() endif() endforeach() @@ -31,6 +34,9 @@ foreach(_target_dep ${_target_deps}) PATHS @find_dependency_paths@ ${QT_EXAMPLES_CMAKE_PREFIX_PATH} NO_DEFAULT_PATH ) endif() -endforeach() -set(@target@_FOUND TRUE) + if (NOT ${pkg}_FOUND) + set(@target@_FOUND FALSE) + return() + endif() +endforeach()