From f3cd57168731c67afd12d8071ead96eed1177b25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 18 Jul 2022 16:22:16 +0200 Subject: qmake: Link static plugins even in shared Qt builds It's perfectly possible to create static plugins in an otherwise shared Qt build, but the logic to import these plugins into applications was assuming a fully static Qt build. We now handle this more granularly. Change-Id: Iacfa72f04c7918613b50ca87cf123e7f4c0841d5 Reviewed-by: Alexandru Croitor --- mkspecs/features/qt.prf | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) (limited to 'mkspecs/features/qt.prf') diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index d08cf264a8..71b6679af3 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -76,7 +76,7 @@ all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_d QTPLUGIN = $$unique($$list($$lower($$QTPLUGIN))) # Sanitize requested plugins, and add any default plugins -import_plugins:qtConfig(static) { +import_plugins { manualplugs = $$QTPLUGIN # User may specify plugins. Mostly legacy. autoplugs = # Auto-added plugins. # First round: explicitly specified modules. @@ -129,14 +129,16 @@ import_plugins:qtConfig(static) { warning("Redundant entries in QTPLUGIN: $$extraplugs") } -# Only link against plugins in static builds -!isEmpty(QTPLUGIN):qtConfig(static) { - IMPORT_FILE_CONT = \ - "// This file is autogenerated by qmake. It imports static plugin classes for" \ - "// static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS. variables." \ - "$${LITERAL_HASH}include " - +# Link static plugins +!isEmpty(QTPLUGIN) { for (plug, QTPLUGIN) { + module_config = $$eval(QT_PLUGIN.$${plug}.module_config) + isEmpty(module_config):!qtConfig(static): \ + next() # Compatibility with older modules + + !contains(module_config, staticlib): \ + next() + plug_class = $$eval(QT_PLUGIN.$${plug}.CLASS_NAME) !isEmpty(plug_class): \ IMPORT_FILE_CONT += "Q_IMPORT_PLUGIN($$plug_class)" @@ -161,12 +163,20 @@ import_plugins:qtConfig(static) { } } - TARGET_BASENAME = $$lower($$basename(TARGET)) - TARGET_BASENAME ~= s/\s/_/g - IMPORT_CPP = $$OUT_PWD/$${TARGET_BASENAME}_plugin_import.cpp - write_file($$IMPORT_CPP, IMPORT_FILE_CONT)|error() - GENERATED_SOURCES += $$IMPORT_CPP - QMAKE_DISTCLEAN += $$IMPORT_CPP + !isEmpty(IMPORT_FILE_CONT) { + IMPORT_FILE_CONT = \ + "// This file is autogenerated by qmake. It imports static plugin classes for" \ + "// static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS. variables." \ + "$${LITERAL_HASH}include " \ + "$$IMPORT_FILE_CONT" + + TARGET_BASENAME = $$lower($$basename(TARGET)) + TARGET_BASENAME ~= s/\s/_/g + IMPORT_CPP = $$OUT_PWD/$${TARGET_BASENAME}_plugin_import.cpp + write_file($$IMPORT_CPP, IMPORT_FILE_CONT)|error() + GENERATED_SOURCES += $$IMPORT_CPP + QMAKE_DISTCLEAN += $$IMPORT_CPP + } } # target variable, flag source variable -- cgit v1.2.3