From 6dd98369b8254e17dc5a43504ea5e592ad73b05e Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 15 Feb 2024 21:51:48 +0100 Subject: [PATCH] Allow configuring network information plugins --- cmake/modules/QtConfig.cmake | 28 ++++++++++++++++++++++++++++ cmake/templates/qtconfig.h.in | 1 + resources/importplugin.h | 1 + 3 files changed, 30 insertions(+) diff --git a/cmake/modules/QtConfig.cmake b/cmake/modules/QtConfig.cmake index e063af8..f7dd114 100644 --- a/cmake/modules/QtConfig.cmake +++ b/cmake/modules/QtConfig.cmake @@ -280,6 +280,34 @@ if (STATIC_LINKAGE OR QT_TARGET_TYPE STREQUAL STATIC_LIBRARY) endif () endif () + if (NETWORK_INFORMATION_SUPPORT) + set(KNOWN_NETWORK_INFORMATION_PLUGINS + ${META_NETWORK_INFORMATION_PLUGINS} NetworkManagerNetworkInformation GlibNetworkInformation NLMNI + AndroidNetworkInformation SCNetworkReachabilityNetworkInformation) + set(USED_NETWORK_INFORMATION_PLUGINS) + foreach (PLUGIN ${KNOWN_NETWORK_INFORMATION_PLUGINS}) + if (TARGET "${QT_PACKAGE_PREFIX}::Q${PLUGIN}Plugin") + use_qt_module( + LIBRARIES_VARIABLE + "${QT_PLUGINS_LIBRARIES_VARIABLE}" + PREFIX + "${QT_PACKAGE_PREFIX}" + MODULE + Network + PLUGINS + ${PLUGIN} + ONLY_PLUGINS) + list(APPEND USED_NETWORK_INFORMATION_PLUGINS "${PLUGIN}") + endif () + endforeach () + + # allow importing network information plugins via qtconfig.h + if (USED_NETWORK_INFORMATION_PLUGINS) + list_to_string(" " "\\\n Q_IMPORT_PLUGIN(Q" ")" "${USED_NETWORK_INFORMATION_PLUGINS}" + USED_NETWORK_INFORMATION_PLUGINS_ARRAY) + endif () + endif () + # ensure all available widget style plugins are built-in when creating a Qt Widgets application - required since Qt 5.10 # because the styles have been "pluginized" (see commit 4f3249f) set(KNOWN_WIDGET_STYLE_PLUGINS ModernWindowsStyle WindowsVistaStyle MacStyle AndroidStyle) diff --git a/cmake/templates/qtconfig.h.in b/cmake/templates/qtconfig.h.in index f629b88..d0aa194 100644 --- a/cmake/templates/qtconfig.h.in +++ b/cmake/templates/qtconfig.h.in @@ -13,5 +13,6 @@ #define IMPORT_IMAGE_FORMAT_PLUGINS @IMAGE_FORMAT_SUPPORT_ARRAY@ #define IMPORT_WIDGET_STYLE_PLUGINS @WIDGET_STYLE_PLUGINS_ARRAY@ #define IMPORT_TLS_PLUGINS @USED_TLS_PLUGINS_ARRAY@ +#define IMPORT_NETWORK_INFORMATION_PLUGINS @USED_NETWORK_INFORMATION_PLUGINS_ARRAY@ @META_CUSTOM_QT_CONFIG@ #endif // @META_PROJECT_VARNAME_UPPER@_QT_CONFIG diff --git a/resources/importplugin.h b/resources/importplugin.h index 240a947..6b63312 100644 --- a/resources/importplugin.h +++ b/resources/importplugin.h @@ -24,6 +24,7 @@ IMPORT_IMAGE_FORMAT_PLUGINS IMPORT_WIDGET_STYLE_PLUGINS #endif // defined(QT_UTILITIES_GUI_QTWIDGETS) || defined(QT_UTILITIES_GUI_QTQUICK) IMPORT_TLS_PLUGINS +IMPORT_NETWORK_INFORMATION_PLUGINS #endif // QT_STATIC #endif // MISC_UTILS_IMPORT_PLUGIN_H