qt5base-lts/cmake/QtConfigDependencies.cmake.in
Alexandru Croitor b6c5e06676 CMake: Handle OPTIONAL_COMPONENTS in qt_find_package
The optional components arguments were not handled before which
caused the recorded package information for static builds to be
incorrect, it only recorded the package name without the component.

Remove REQUIRED_COMPONENTS TODO, there is no such find_package option,
it's already handled by the regular COMPONENTS code path.

Amends 07b6d3367d

Pick-to: 6.1 6.2
Fixes: QTBUG-94501
Change-Id: Ib48a7befcb70e20c3f21315897d51d3064b48134
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-06-17 23:28:18 +02:00

53 lines
1.9 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)
list(GET _target_dep 4 optional_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()
if(optional_components)
string(REPLACE " " ";" optional_components "${optional_components}")
list(APPEND find_package_args OPTIONAL_COMPONENTS ${optional_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()
if(optional_components)
string(APPEND __@INSTALL_CMAKE_NAMESPACE@_message "\nComponents: ${optional_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)