~alan-griffiths/miral/fix-1645284

« back to all changes in this revision

Viewing changes to miral-qt/cmake/modules/QmlPlugins.cmake

  • Committer: Alan Griffiths
  • Date: 2016-11-07 17:59:19 UTC
  • mfrom: (436.1.1 miral2)
  • Revision ID: alan@octopull.co.uk-20161107175919-stbb64i7j1htgog2
[miral-qt] delete all as qtmir work on MirAL has shifted to lp:~unity-team/qtmir/miral-qt-integration and this is a needless distration

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# If you need to override the qmlplugindump binary, create the qmlplugin executable
2
 
# target before loading this plugin.
3
 
 
4
 
if(NOT TARGET qmlplugindump)
5
 
    find_program(qmlplugindump_exe qmlplugindump)
6
 
 
7
 
    if(NOT qmlplugindump_exe)
8
 
      msg(FATAL_ERROR "Could not locate qmlplugindump.")
9
 
    endif()
10
 
 
11
 
    add_executable(qmlplugindump IMPORTED)
12
 
    set_target_properties(qmlplugindump PROPERTIES IMPORTED_LOCATION ${qmlplugindump_exe})
13
 
endif()
14
 
 
15
 
#
16
 
# A custom target for building the qmltypes files manually.
17
 
#
18
 
if (NOT TARGET qmltypes)
19
 
    add_custom_target(qmltypes)
20
 
endif()
21
 
 
22
 
# Creates a target for copying resource files into build dir and optionally installing them.
23
 
#
24
 
# Files will be copied into ${BINARY_DIR}/${path} or ${CMAKE_CURRENT_BINARY_DIR} and installed
25
 
# into ${DESTINATION}/${path}.
26
 
#
27
 
# Resource file names are matched against {*.{qml,js,jpg,png,sci,svg},qmldir}.
28
 
#
29
 
# export_qmlfiles(plugin path
30
 
#     [SEARCH_PATH path]      # Path to search for resources in (defaults to ${CMAKE_CURRENT_SOURCE_DIR})
31
 
#     [BINARY_DIR path]
32
 
#     [DESTINATION path]
33
 
#     [TARGET_PREFIX string]  # Will be prefixed to the target name
34
 
# )
35
 
#
36
 
# Created target:
37
 
#   - ${TARGET_PREFIX}${plugin}-qmlfiles - Copies resources into the binary dir.
38
 
 
39
 
macro(export_qmlfiles PLUGIN PATH)
40
 
    set(single SEARCH_PATH BINARY_DIR DESTINATION TARGET_PREFIX)
41
 
    cmake_parse_arguments(QMLFILES "" "${single}" "" ${ARGN})
42
 
 
43
 
    if(NOT QMLFILES_SEARCH_PATH)
44
 
        set(QMLFILES_SEARCH_PATH ${CMAKE_CURRENT_SOURCE_DIR})
45
 
    endif()
46
 
 
47
 
    if(QMLFILES_BINARY_DIR)
48
 
        set(qmlfiles_dir ${QMLFILES_BINARY_DIR}/${PATH})
49
 
    else()
50
 
        set(qmlfiles_dir ${CMAKE_CURRENT_BINARY_DIR})
51
 
    endif()
52
 
 
53
 
    file(GLOB QMLFILES
54
 
        ${QMLFILES_SEARCH_PATH}/*.qml
55
 
        ${QMLFILES_SEARCH_PATH}/*.js
56
 
        ${QMLFILES_SEARCH_PATH}/*.jpg
57
 
        ${QMLFILES_SEARCH_PATH}/*.png
58
 
        ${QMLFILES_SEARCH_PATH}/*.sci
59
 
        ${QMLFILES_SEARCH_PATH}/*.svg
60
 
        ${QMLFILES_SEARCH_PATH}/*.qmltypes
61
 
        ${QMLFILES_SEARCH_PATH}/qmldir
62
 
    )
63
 
 
64
 
    execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${qmlfiles_dir})
65
 
 
66
 
    # copy the files
67
 
    add_custom_target(${QMLFILES_TARGET_PREFIX}${PLUGIN}-qmlfiles ALL
68
 
                        COMMAND cp ${QMLFILES} ${qmlfiles_dir}
69
 
                        DEPENDS ${QMLFILES}
70
 
                        SOURCES ${QMLFILES}
71
 
    )
72
 
 
73
 
    if(QMLFILES_DESTINATION)
74
 
        # install the qmlfiles file.
75
 
        install(FILES ${QMLFILES}
76
 
            DESTINATION ${QMLFILES_DESTINATION}/${PATH}
77
 
        )
78
 
    endif()
79
 
endmacro()
80
 
 
81
 
 
82
 
# Creates a target for generating the typeinfo file for a QML plugin and/or installs the plugin
83
 
# targets.
84
 
#
85
 
# Files will be copied into ${BINARY_DIR}/${path} or ${CMAKE_CURRENT_BINARY_DIR} and installed
86
 
# into ${DESTINATION}/${path}. If you don't pass BINARY_DIR, it's assumed that current source
87
 
# path ends with ${path}.
88
 
#
89
 
# The generated file will be named after the last segment of the plugin name, e.g. Foo.qmltypes.
90
 
#
91
 
# export_qmlplugin(plugin version path
92
 
#     [BINARY_DIR path]
93
 
#     [DESTINATION path]
94
 
#     [TARGET_PREFIX string]  # Will be prefixed to the target name
95
 
#     [ENVIRONMENT string]    # Will be added to qmlplugindump's env
96
 
#     [TARGETS target1 [target2 ...]] # Targets to depend on and install (e.g. the plugin shared object)
97
 
#     [NO_TYPES] # Do not create the qmltypes target
98
 
# )
99
 
#
100
 
# Created target:
101
 
#   - ${TARGET_PREFIX}${plugin}-qmltypes - Generates the qmltypes file in the source dir.
102
 
#     It will be made a dependency of the "qmltypes" target.
103
 
 
104
 
macro(export_qmlplugin PLUGIN VERSION PATH)
105
 
    set(options NO_TYPES)
106
 
    set(single BINARY_DIR DESTINATION TARGET_PREFIX ENVIRONMENT)
107
 
    set(multi TARGETS)
108
 
    cmake_parse_arguments(QMLPLUGIN "${options}" "${single}" "${multi}" ${ARGN})
109
 
 
110
 
    get_target_property(qmlplugindump_executable qmlplugindump LOCATION)
111
 
 
112
 
    if(QMLPLUGIN_BINARY_DIR)
113
 
        set(qmlplugin_dir ${QMLPLUGIN_BINARY_DIR}/${PATH})
114
 
    else()
115
 
        # Find import path to point qmlplugindump at
116
 
        string(REGEX REPLACE "/${PATH}$" "" QMLPLUGIN_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
117
 
        set(qmlplugin_dir ${CMAKE_CURRENT_BINARY_DIR})
118
 
    endif()
119
 
 
120
 
    if(NOT QMLPLUGIN_NO_TYPES)
121
 
        # Relative path for the module
122
 
        string(REPLACE "${CMAKE_BINARY_DIR}/" "" QMLPLUGIN_MODULE_DIR "${QMLPLUGIN_BINARY_DIR}")
123
 
 
124
 
        # Find the last segment of the plugin name to use as qmltypes basename
125
 
        string(REGEX MATCH "[^.]+$" plugin_suffix ${PLUGIN})
126
 
        set(target_prefix ${QMLPLUGIN_TARGET_PREFIX}${PLUGIN})
127
 
        set(qmltypes_path ${CMAKE_CURRENT_SOURCE_DIR}/${plugin_suffix}.qmltypes)
128
 
 
129
 
        add_custom_target(${target_prefix}-qmltypes
130
 
            COMMAND env ${QMLPLUGIN_ENVIRONMENT} ${qmlplugindump_executable} -notrelocatable
131
 
                    ${PLUGIN} ${VERSION} ${QMLPLUGIN_MODULE_DIR} > ${qmltypes_path}
132
 
                    WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
133
 
        )
134
 
        add_dependencies(${target_prefix}-qmltypes ${target_prefix}-qmlfiles ${QMLPLUGIN_TARGETS})
135
 
        add_dependencies(qmltypes ${target_prefix}-qmltypes)
136
 
    endif()
137
 
 
138
 
    set_target_properties(${QMLPLUGIN_TARGETS} PROPERTIES
139
 
                          ARCHIVE_OUTPUT_DIRECTORY ${qmlplugin_dir}
140
 
                          LIBRARY_OUTPUT_DIRECTORY ${qmlplugin_dir}
141
 
                          RUNTIME_OUTPUT_DIRECTORY ${qmlplugin_dir}
142
 
    )
143
 
 
144
 
    if (QMLPLUGIN_DESTINATION)
145
 
        # Install additional targets
146
 
        install(TARGETS ${QMLPLUGIN_TARGETS}
147
 
                DESTINATION ${QMLPLUGIN_DESTINATION}/${PATH}
148
 
        )
149
 
    endif()
150
 
endmacro()