on 39cfda5 help sign in
unity8/cmake/modules/Plugins.cmake
68 lines 2.2 kB history raw
1find_program(qmlplugindump_exe qmlplugindump)
3if(NOT qmlplugindump_exe)
4 msg(FATAL_ERROR "Could not locate qmlplugindump.")
5endif()
7# Creates target for copying and installing qmlfiles
8#
9# export_qmlfiles(plugin sub_path)
12# Target to be created:
13# - plugin-qmlfiles - Copies the qml files (*.qml, *.js, qmldir) into the shadow build folder.
15macro(export_qmlfiles PLUGIN PLUGIN_SUBPATH)
17 file(GLOB QMLFILES
18 *.qml
19 *.js
20 qmldir
21 )
23 # copy the qmldir file
24 add_custom_target(${PLUGIN}-qmlfiles ALL
25 COMMAND cp ${QMLFILES} ${CMAKE_BINARY_DIR}/plugins/${PLUGIN_SUBPATH}
26 DEPENDS ${QMLFILES}
27 SOURCES ${QMLFILES}
28 )
30 # install the qmlfiles file.
31 install(FILES ${QMLFILES}
32 DESTINATION ${SHELL_INSTALL_QML}/${PLUGIN_SUBPATH}
33 )
34endmacro(export_qmlfiles)
37# Creates target for generating the qmltypes file for a plugin and installs plugin files
39# export_qmlplugin(plugin version sub_path [TARGETS target1 [target2 ...]])
41# TARGETS additional install targets (eg the plugin shared object)
43# Target to be created:
44# - plugin-qmltypes - Generates the qmltypes file in the shadow build folder.
46macro(export_qmlplugin PLUGIN VERSION PLUGIN_SUBPATH)
47 set(multi_value_keywords TARGETS)
48 cmake_parse_arguments(qmlplugin "" "" "${multi_value_keywords}" ${ARGN})
50 # Only try to generate .qmltypes if not cross compiling
51 if(NOT CMAKE_CROSSCOMPILING)
52 # create the plugin.qmltypes file
53 add_custom_target(${PLUGIN}-qmltypes ALL
54 COMMAND ${qmlplugindump_exe} -notrelocatable ${PLUGIN} ${VERSION} ${CMAKE_BINARY_DIR}/plugins > ${CMAKE_BINARY_DIR}/plugins/${PLUGIN_SUBPATH}/plugin.qmltypes
55 )
56 add_dependencies(${PLUGIN}-qmltypes ${PLUGIN}-qmlfiles ${qmlplugin_TARGETS})
58 # install the qmltypes file.
59 install(FILES ${CMAKE_BINARY_DIR}/plugins/${PLUGIN_SUBPATH}/plugin.qmltypes
60 DESTINATION ${SHELL_INSTALL_QML}/${PLUGIN_SUBPATH}
61 )
62 endif()
64 # install the additional targets
65 install(TARGETS ${qmlplugin_TARGETS}
66 DESTINATION ${SHELL_INSTALL_QML}/${PLUGIN_SUBPATH}
67 )
68endmacro(export_qmlplugin)