on 551c708 help sign in
unity8/cmake/modules/Plugins.cmake
67 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 )
29 # install the qmlfiles file.
30 install(FILES ${QMLFILES}
31 DESTINATION ${SHELL_INSTALL_QML}/${PLUGIN_SUBPATH}
32 )
33endmacro(export_qmlfiles)
36# Creates target for generating the qmltypes file for a plugin and installs plugin files
38# export_qmlplugin(plugin version sub_path [TARGETS target1 [target2 ...]])
40# TARGETS additional install targets (eg the plugin shared object)
42# Target to be created:
43# - plugin-qmltypes - Generates the qmltypes file in the shadow build folder.
45macro(export_qmlplugin PLUGIN VERSION PLUGIN_SUBPATH)
46 set(multi_value_keywords TARGETS)
47 cmake_parse_arguments(qmlplugin "" "" "${multi_value_keywords}" ${ARGN})
49 # Only try to generate .qmltypes if not cross compiling
50 if(NOT CMAKE_CROSSCOMPILING)
51 # create the plugin.qmltypes file
52 add_custom_target(${PLUGIN}-qmltypes ALL
53 COMMAND ${qmlplugindump_exe} -notrelocatable ${PLUGIN} ${VERSION} ${CMAKE_BINARY_DIR}/plugins > ${CMAKE_BINARY_DIR}/plugins/${PLUGIN_SUBPATH}/plugin.qmltypes
54 )
55 add_dependencies(${PLUGIN}-qmltypes ${PLUGIN}-qmlfiles ${qmlplugin_TARGETS})
57 # install the qmltypes file.
58 install(FILES ${CMAKE_BINARY_DIR}/plugins/${PLUGIN_SUBPATH}/plugin.qmltypes
59 DESTINATION ${SHELL_INSTALL_QML}/${PLUGIN_SUBPATH}
60 )
61 endif()
63 # install the additional targets
64 install(TARGETS ${qmlplugin_TARGETS}
65 DESTINATION ${SHELL_INSTALL_QML}/${PLUGIN_SUBPATH}
66 )
67endmacro(export_qmlplugin)