From f166fcd3d0931ecc08087b12fdac5940e5ccbdf7 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 10 Dec 2012 15:56:29 +0200 Subject: Pro-file level support for importing plugins for static Qt builds Platform plugin is needed always when gui is linked to an application. This is tedious to do manually for static builds, so provide support for generating a source file that imports static plugins for application projects. "CONFIG += import_plugins" statement in application .pro file will generate required import statements for all plugins specified with QTPLUGIN variable. The plugin class names are found from plugin's module pri generated automatically when plugin is built, as long as the plugin specifies the PLUGIN_CLASS_NAME in the plugin .pro file before loading qt_plugin.prf. Task-number: QTBUG-28131 Change-Id: I19f8ea48a3c1e9b5c81f4399c4b5d439a6d4bea1 Reviewed-by: Oswald Buddenhagen --- mkspecs/features/qt.prf | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'mkspecs/features/qt.prf') diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index 443914e011..6b2833b09e 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -36,7 +36,30 @@ plugin { #Qt plugins } QT_PLUGIN_VERIFY = DEPLOYMENT_PLUGIN -contains(QT_CONFIG, static): QT_PLUGIN_VERIFY += QTPLUGIN + +contains(QT_CONFIG, static) { + QT_PLUGIN_VERIFY += QTPLUGIN + contains(TEMPLATE, .*app) { + import_plugins:!isEmpty(QTPLUGIN) { + 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 " + for(IMPORT_PLUG, $$list($$unique(QTPLUGIN))) { + PLUG_CLASS = $$eval(QT_PLUGIN.$${IMPORT_PLUG}.CLASS_NAME) + !isEmpty(PLUG_CLASS): \ + IMPORT_FILE_CONT += "Q_IMPORT_PLUGIN($$PLUG_CLASS)" + else: \ + warning("Plugin class name could not be determined for $$IMPORT_PLUG plugin.") + } + IMPORT_CPP = $$OUT_PWD/$$lower($$basename(TARGET))_plugin_import.cpp + write_file($$IMPORT_CPP, IMPORT_FILE_CONT)|error("Aborting.") + SOURCES += $$IMPORT_CPP + QMAKE_DISTCLEAN += $$IMPORT_CPP + } + } +} + for(QT_CURRENT_VERIFY, $$list($$QT_PLUGIN_VERIFY)) { for(QTPLUG, $$list($$lower($$unique($$QT_CURRENT_VERIFY)))) { # Check if the plugin is known to Qt. We can use this to determine -- cgit v1.2.3