summaryrefslogtreecommitdiffstats
path: root/cmake/QtPluginDependencies.cmake.in
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2020-09-09 16:19:11 +0200
committerJoerg Bornemann <joerg.bornemann@qt.io>2020-09-12 19:26:58 +0200
commit3685483c4b79b4075bab6d341174a395359d1b4a (patch)
treee27e0dc368cc7d712cc8cd91c8f787e0151caf8d /cmake/QtPluginDependencies.cmake.in
parenta3cb002511d7e2cc73234611795c1947620aedd5 (diff)
CMake: Add facility to mark package dependencies as optional
Every public dependency of a Qt module results in a find_package call in the consuming project. But not all public dependencies are mandatory. For example, vulkan is only needed if the user project actually uses Qt classes that pull in vulkan headers. This patch adds the option MARK_OPTIONAL to qt_find_package. Dependencies that are marked as optional will not produce an error on find failure. Task-number: QTBUG-86421 Change-Id: Ia767e7f36991e236582c7509cbd37ea3487bb695 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtPluginDependencies.cmake.in')
-rw-r--r--cmake/QtPluginDependencies.cmake.in16
1 files changed, 12 insertions, 4 deletions
diff --git a/cmake/QtPluginDependencies.cmake.in b/cmake/QtPluginDependencies.cmake.in
index bae6d85c7b..9d16bedeba 100644
--- a/cmake/QtPluginDependencies.cmake.in
+++ b/cmake/QtPluginDependencies.cmake.in
@@ -1,12 +1,13 @@
set(@target@_FOUND FALSE)
-# note: _third_party_deps example: "ICU\\;1.0\\;i18n uc data;ZLIB\\;\\;"
+# note: _third_party_deps example: "ICU\\;FALSE\\;1.0\\;i18n uc data;ZLIB\\;FALSE\\;\\;"
set(_third_party_deps "@third_party_deps@")
foreach(_target_dep ${_third_party_deps})
list(GET _target_dep 0 pkg)
- list(GET _target_dep 1 version)
- list(GET _target_dep 2 components)
+ 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}")
@@ -16,7 +17,14 @@ foreach(_target_dep ${_third_party_deps})
list(APPEND find_package_args COMPONENTS ${components})
endif()
- find_dependency(${find_package_args})
+ 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()
# note: target_deps example: "Qt6Core\;5.12.0;Qt6Gui\;5.12.0"