summaryrefslogtreecommitdiffstats
path: root/mkspecs/features/resources.prf
diff options
context:
space:
mode:
Diffstat (limited to 'mkspecs/features/resources.prf')
-rw-r--r--mkspecs/features/resources.prf34
1 files changed, 34 insertions, 0 deletions
diff --git a/mkspecs/features/resources.prf b/mkspecs/features/resources.prf
index ff45446219..9fed6387c8 100644
--- a/mkspecs/features/resources.prf
+++ b/mkspecs/features/resources.prf
@@ -72,6 +72,40 @@ for(resource, RESOURCES) {
RESOURCES += $$resource_file
}
+!isEmpty(RESOURCES):contains(TEMPLATE, .*lib):plugin:static {
+ pluginName = $$lower($$replace(_PRO_FILE_, .*/([^/.]+)\\.[^/.]+, \\1))
+
+ resource_init_function = $${pluginName}_plugin_resource_init
+ DEFINES += "QT_PLUGIN_RESOURCE_INIT_FUNCTION=$$resource_init_function"
+
+ RESOURCE_INIT_CPP = $$OUT_PWD/$${pluginName}_plugin_resources.cpp
+
+ GENERATED_SOURCES += $$RESOURCE_INIT_CPP
+ QMAKE_DISTCLEAN += $$RESOURCE_INIT_CPP
+
+ !build_pass {
+ RESOURCE_INIT_CONT = \
+ "// This file is autogenerated by qmake. It contains a function that" \
+ "// references all resources the plugin includes and the function is" \
+ "// referenced by Qt_(MOC_)EXPORT_PLUGIN to ensure the inclusion in" \
+ "// the statically linked plugin." \
+ "$${LITERAL_HASH}include <QtCore/qglobal.h>" \
+ "void $${resource_init_function}() " \
+ "{" \
+
+ for (resource, RESOURCES) {
+ resource_name = $$section($$list($$basename(resource)), ., 0, 0)
+ resource_name = $$replace(resource_name, [^a-zA-Z0-9_], _)
+ RESOURCE_INIT_CONT += " Q_INIT_RESOURCE($$resource_name);"
+ }
+
+ RESOURCE_INIT_CONT += \
+ "}"
+
+ write_file($$RESOURCE_INIT_CPP, RESOURCE_INIT_CONT)|error()
+ }
+}
+
rcc.input = RESOURCES
rcc.name = RCC ${QMAKE_FILE_IN}
rcc.depend_command = $$QMAKE_RCC_DEP -list $$QMAKE_RESOURCE_FLAGS ${QMAKE_FILE_IN}