diff --git a/cmake/modules/QtConfig.cmake b/cmake/modules/QtConfig.cmake index da660da..7cd4383 100644 --- a/cmake/modules/QtConfig.cmake +++ b/cmake/modules/QtConfig.cmake @@ -110,6 +110,15 @@ foreach (MODULE ${IMPORTED_KF_MODULES}) endif () endforeach () +# enable TLS support by default when using Qt Network (relevant for linking against static plugin) +if (NOT DEFINED TLS_SUPPORT) + if (Network IN_LIST QT_MODULES OR Network IN_LIST IMPORTED_QT_MODULES) + set(TLS_SUPPORT ON) + else () + set(TLS_SUPPORT OFF) + endif () +endif () + # built-in platform, imageformat and iconengine plugins when linking statically against Qt if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION) message(STATUS "Linking application ${META_PROJECT_NAME} against Qt plugins because static linkage is enabled.") @@ -149,6 +158,32 @@ if (STATIC_LINKAGE AND META_PROJECT_IS_APPLICATION) endif () endif () + # ensure a TLS plugin is built-in when available and when creating an app using Qt Network - required since Qt 6.2.0 + # which "pluginized" TLS support + if (TLS_SUPPORT) + set(KNOWN_TLS_PLUGINS ${META_TLS_PLUGINS} SchannelBackend TlsBackendOpenSSL) + set(USED_TLS_PLUGINS) + foreach (TLS_PLUGIN ${KNOWN_TLS_PLUGINS}) + if (TARGET "${QT_PACKAGE_PREFIX}::Q${TLS_PLUGIN}Plugin") + use_qt_module( + PREFIX + "${QT_PACKAGE_PREFIX}" + MODULE + Network + PLUGINS + ${TLS_PLUGIN} + ONLY_PLUGINS) + list(APPEND USED_TLS_PLUGINS "${TLS_PLUGIN}") + break() # one plugin is sufficient + endif () + endforeach () + + # allow importing TLS plugins via qtconfig.h + if (USED_TLS_PLUGINS) + list_to_string(" " "\\\n Q_IMPORT_PLUGIN(Q" ")" "${USED_TLS_PLUGINS}" USED_TLS_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 WindowsVistaStyle MacStyle AndroidStyle) diff --git a/cmake/templates/qtconfig.h.in b/cmake/templates/qtconfig.h.in index 493e14e..f629b88 100644 --- a/cmake/templates/qtconfig.h.in +++ b/cmake/templates/qtconfig.h.in @@ -12,5 +12,6 @@ #cmakedefine IMAGE_FORMAT_SUPPORT #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@ @META_CUSTOM_QT_CONFIG@ #endif // @META_PROJECT_VARNAME_UPPER@_QT_CONFIG diff --git a/resources/importplugin.h b/resources/importplugin.h index 7edc091..240a947 100644 --- a/resources/importplugin.h +++ b/resources/importplugin.h @@ -23,6 +23,7 @@ IMPORT_IMAGE_FORMAT_PLUGINS #endif IMPORT_WIDGET_STYLE_PLUGINS #endif // defined(QT_UTILITIES_GUI_QTWIDGETS) || defined(QT_UTILITIES_GUI_QTQUICK) +IMPORT_TLS_PLUGINS #endif // QT_STATIC #endif // MISC_UTILS_IMPORT_PLUGIN_H