From a4e4f8918183608a0449c5d60622e6b355b8dbbd Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 20 Dec 2016 20:20:39 +0100 Subject: fix up static linking of plugins somewhat move the code before the linking of qt modules - dependency resolution would re-order them anyway (or static linking would fail). on the way, fix up the coding style and rename some variables. the code to de-duplicate/normalize QTPLUGIN is pulled ahead, which means that the automatic plugin importing wouldn't make a mess of it any more. but this is mostly legacy anyway. Change-Id: Id135470d027f5d84b7f30531425a65efa230f278 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt.prf | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 626cf9c809..3ccbbe7061 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -63,6 +63,8 @@ CLEAN_QT_PRIVATE = $$replace(QT_PRIVATE, -private$, _private) qt_module_deps = $$CLEAN_QT $$CLEAN_QT_PRIVATE all_qt_module_deps = $$resolve_depends(qt_module_deps, "QT.", ".depends" ".run_depends") +QTPLUGIN = $$unique($$list($$lower($$QTPLUGIN))) + import_plugins:qtConfig(static) { manualplugs = $$QTPLUGIN # User may specify plugins. Mostly legacy. autoplugs = # Auto-added plugins. @@ -132,6 +134,22 @@ import_plugins:qtConfig(static) { } } +# Only link against plugins in static builds +!isEmpty(QTPLUGIN):qtConfig(static) { + for (plug, QTPLUGIN) { + # Check if the plugin is known to Qt. We can use this to determine + # the plugin path. Unknown plugins must rely on the default link path. + plug_type = $$eval(QT_PLUGIN.$${plug}.TYPE) + !isEmpty(plug_type) { + plug_path = $$eval(QT_PLUGIN.$${plug}.PATH) + isEmpty(plug_path): \ + plug_path = $$[QT_INSTALL_PLUGINS/get] + LIBS += -L$$plug_path/$$plug_type + } + LIBS += -l$${plug}$$qtPlatformTargetSuffix() + } +} + # target variable, flag source variable defineTest(qtProcessModuleFlags) { for(flag, $$2) { @@ -322,24 +340,3 @@ contains(all_qt_module_deps, qml): \ QMAKE_DISTCLEAN += $$QML_IMPORT_CPP } } -qtConfig(static) { - for (QTPLUG, $$list($$lower($$unique(QTPLUGIN)))) { - # Check if the plugin is known to Qt. We can use this to determine - # the plugin path. Unknown plugins must rely on the default link path. - QT_PLUGINPATH = $$eval(QT_PLUGIN.$${QTPLUG}.TYPE) - - # Generate the plugin linker line - QT_LINKAGE = -l$${QTPLUG}$$qtPlatformTargetSuffix() - - # Only link against plugin in static builds - { - !isEmpty(QT_PLUGINPATH) { - plugpath = $$eval(QT_PLUGIN.$${QTPLUG}.PATH) - isEmpty(plugpath): \ - plugpath = $$[QT_INSTALL_PLUGINS/get] - LIBS *= -L$$plugpath/$$QT_PLUGINPATH - } - LIBS += $$QT_LINKAGE - } - } -} -- cgit v1.2.3