on e9eae63 help sign in
unity8/cmake/modules/Plugins.cmake
48 lines 1.7 kB history raw
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.
12macro(export_qmlplugin PLUGIN VERSION PLUGIN_SUBPATH)
13 set(multi_value_keywords TARGETS)
14 cmake_parse_arguments(qmlplugin "" "" "${multi_value_keywords}" ${ARGN})
16 file(GLOB QMLFILES
17 *.qml
18 *.js
19 qmldir
20 )
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 )
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})
34 # install the qmldir file.
35 install(FILES ${QMLFILES}
36 DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/${PLUGIN_SUBPATH}
37 )
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 )
44 # install the additional targets
45 install(TARGETS ${qmlplugin_TARGETS}
46 DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/${PLUGIN_SUBPATH}
47 )
48endmacro(export_qmlplugin)