~ps-jenkins/unity-scopes-shell/ubuntu-rtm-14.09-proposed

« back to all changes in this revision

Viewing changes to cmake/modules/Plugins.cmake

  • Committer: Michal Hruby
  • Date: 2013-11-07 17:48:16 UTC
  • Revision ID: michal.mhr@gmail.com-20131107174816-w1vqq6juarrawx23
Initial commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
find_program(qmlplugindump_exe qmlplugindump)
 
2
 
 
3
if(NOT qmlplugindump_exe)
 
4
  msg(FATAL_ERROR "Could not locate qmlplugindump.")
 
5
endif()
 
6
 
 
7
# Creates target for copying and installing qmlfiles
 
8
#
 
9
# export_qmlfiles(plugin sub_path)
 
10
#
 
11
#
 
12
# Target to be created:
 
13
#   - plugin-qmlfiles - Copies the qml files (*.qml, *.js, qmldir) into the shadow build folder.
 
14
 
 
15
macro(export_qmlfiles PLUGIN PLUGIN_SUBPATH)
 
16
 
 
17
    file(GLOB QMLFILES
 
18
        *.qml
 
19
        *.js
 
20
        qmldir
 
21
    )
 
22
 
 
23
    # copy the qmldir file
 
24
    add_custom_target(${PLUGIN}-qmlfiles ALL
 
25
                        COMMAND cp ${QMLFILES} ${CMAKE_CURRENT_BINARY_DIR}
 
26
                        DEPENDS ${QMLFILES}
 
27
    )
 
28
 
 
29
    # install the qmlfiles file.
 
30
    install(FILES ${QMLFILES}
 
31
        DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/${PLUGIN_SUBPATH}
 
32
    )
 
33
endmacro(export_qmlfiles)
 
34
 
 
35
 
 
36
# Creates target for generating the qmltypes file for a plugin and installs plugin files
 
37
#
 
38
# export_qmlplugin(plugin version sub_path [TARGETS target1 [target2 ...]])
 
39
#
 
40
# TARGETS additional install targets (eg the plugin shared object)
 
41
#
 
42
# Target to be created:
 
43
#   - plugin-qmltypes - Generates the qmltypes file in the shadow build folder.
 
44
 
 
45
macro(export_qmlplugin PLUGIN VERSION PLUGIN_SUBPATH)
 
46
    set(multi_value_keywords TARGETS)
 
47
    cmake_parse_arguments(qmlplugin "" "" "${multi_value_keywords}" ${ARGN})
 
48
 
 
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})
 
56
 
 
57
        # install the qmltypes file.
 
58
        install(FILES ${CMAKE_BINARY_DIR}/plugins/${PLUGIN_SUBPATH}/plugin.qmltypes
 
59
            DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/${PLUGIN_SUBPATH}
 
60
        )
 
61
    endif()
 
62
 
 
63
    # install the additional targets
 
64
    install(TARGETS ${qmlplugin_TARGETS}
 
65
        DESTINATION ${SHELL_PRIVATE_LIBDIR}/qml/${PLUGIN_SUBPATH}
 
66
    )
 
67
endmacro(export_qmlplugin)