diff options
author | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-09-11 13:41:39 +0200 |
---|---|---|
committer | Joerg Bornemann <joerg.bornemann@qt.io> | 2020-09-12 19:26:52 +0200 |
commit | 58c1c6ee5c986d502b56eb1cc57f1d9444d42031 (patch) | |
tree | 19689d29d176e78ee7fb0fcc3f77b3b225d6baca /cmake/QtConfigDependencies.cmake.in | |
parent | 55687924e3cc40b1ffc5a9038bb7e37d1ed6a19c (diff) |
CMake: Fix usage of find_dependency()
The find_dependency() macro calls return() on failure, meaning any code
after it will be ignored, thus checking any XXX_FOUND variables after
find_dependency() is pointless.
Fix the places where we use find_dependency() and set the "failed" state
before the call and the "success" state afterwards.
Change-Id: Ia5239c704f02a9bec972210374ffed7808b14055
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtConfigDependencies.cmake.in')
-rw-r--r-- | cmake/QtConfigDependencies.cmake.in | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/cmake/QtConfigDependencies.cmake.in b/cmake/QtConfigDependencies.cmake.in index 301d808d8c..e16d725928 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() - - 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() + +set(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCIES_FOUND TRUE) +unset(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCY_NOT_FOUND_MESSAGE) |