qt5base-lts/cmake/QtConfigDependencies.cmake.in
Joerg Bornemann 6718dea390 Revert "Revert "CMake: Add facility to mark package dependencies as optional""
This reverts commit b0c51f86f4.
The build failure caused by 58c1c6ee5c has
been fixed.

Change-Id: Ic7458d54c7a874588e8b1bfeca61df1842763656
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-09-14 15:03:14 +02:00

45 lines
1.5 KiB
CMake

set(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCIES_FOUND FALSE)
# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;"
set(_third_party_deps "@third_party_deps@")
@third_party_extra@
foreach(_target_dep ${_third_party_deps})
list(GET _target_dep 0 pkg)
list(GET _target_dep 1 is_optional)
list(GET _target_dep 2 version)
list(GET _target_dep 3 components)
set(find_package_args "${pkg}")
if(version)
list(APPEND find_package_args "${version}")
endif()
if(components)
string(REPLACE " " ";" components "${components}")
list(APPEND find_package_args COMPONENTS ${components})
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(is_optional)
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
list(APPEND find_package_args QUIET)
endif()
find_package(${find_package_args})
else()
find_dependency(${find_package_args})
endif()
endforeach()
set(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCIES_FOUND TRUE)
unset(@INSTALL_CMAKE_NAMESPACE@_DEPENDENCY_NOT_FOUND_MESSAGE)