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 <joerg.bornemann@qt.io>
This commit is contained in:
Oswald Buddenhagen 2016-12-20 20:20:39 +01:00
parent 6b070340a8
commit a4e4f89181

View File

@ -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
}
}
}