@@ -0,0 +1,48 @@
1+# Creates targets for copying and installing qmlfiles and generating the qmltypes file for a plugin
2+#
3+# export_qmlplugin(plugin version sub_path [TARGETS target1 [target2 ...]])
4+#
5+# TARGETS additional install targets (eg the plugin shared object)
6+#
7+# Two targets will be created:
8+# - plugin-qmlfiles - Copies the qml files (*.qml, *.js, qmldir) into the shadow build folder.
9+# - plugin-qmltypes - Generates the qmltypes file in the shadow build folder.
10+
11+
12+macro(export_qmlplugin PLUGIN VERSION PLUGIN_SUBPATH)
13+ set(multi_value_keywords TARGETS)
14+ cmake_parse_arguments(qmlplugin "" "" "${multi_value_keywords}" ${ARGN})
15+
16+ file(GLOB QMLFILES
17+ *.qml
18+ *.js
19+ qmldir
20+ )
21+
22+ # copy the qmldir file
23+ add_custom_target(${PLUGIN}-qmlfiles ALL
24+ COMMAND cp ${QMLFILES} ${CMAKE_BINARY_DIR}/plugins/${PLUGIN_SUBPATH}
25+ DEPENDS ${QMLFILES}
26+ )
27+
28+ # create the plugin.qmltypes file
29+ add_custom_target(${PLUGIN}-qmltypes ALL
30+ COMMAND qmlplugindump -notrelocatable ${PLUGIN} ${VERSION} ${CMAKE_BINARY_DIR}/plugins > ${CMAKE_BINARY_DIR}/plugins/${PLUGIN_SUBPATH}/plugin.qmltypes
31+ )
32+ add_dependencies(${PLUGIN}-qmltypes ${PLUGIN}-qmlfiles ${qmlplugin_TARGETS})
33+
34+ # install the qmldir file.
35+ install(FILES ${QMLFILES}
36+ DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/${PLUGIN_SUBPATH}
37+ )
38+
39+ # install the qmltypes file.
40+ install(FILES ${CMAKE_BINARY_DIR}/plugins/${PLUGIN_SUBPATH}/plugin.qmltypes
41+ DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/${PLUGIN_SUBPATH}
42+ )
43+
44+ # install the additional targets
45+ install(TARGETS ${qmlplugin_TARGETS}
46+ DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/${PLUGIN_SUBPATH}
47+ )
48+endmacro(export_qmlplugin)