diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-07-18 16:22:16 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2022-07-25 18:02:37 +0200 |
commit | f3cd57168731c67afd12d8071ead96eed1177b25 (patch) | |
tree | cb0a1d0447f11689ce15cba22ac15e727cd8d86a /mkspecs/features/qt.prf | |
parent | 6ebc4249e23a323a56245f046b5842cedb9e92fb (diff) |
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 <alexandru.croitor@qt.io>
Diffstat (limited to 'mkspecs/features/qt.prf')
-rw-r--r-- | mkspecs/features/qt.prf | 38 |
1 files changed, 24 insertions, 14 deletions
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.<plugin> variables." \ - "$${LITERAL_HASH}include <QtPlugin>" - +# 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.<plugin> variables." \ + "$${LITERAL_HASH}include <QtPlugin>" \ + "$$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 |