File: gresource.cmake

package info (click to toggle)
fcitx-configtool 0.4.10-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 704 kB
  • sloc: ansic: 6,774; sh: 16; xml: 7; makefile: 7
file content (58 lines) | stat: -rw-r--r-- 1,920 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Used for GResource.
#
# resource_dir: Directory where the .gresource.xml is located.
# resource_file: Filename of the .gresource.xml file (just the
# filename, not the complete path).
# output_dir: Directory where the C output file is written.
# output_file: This variable will be set with the complete path of the
# output C file.

function (gresource resource_dir resource_file output_dir output_source output_header)

_pkgconfig_invoke("glib-2.0" GLIB2 PREFIX
  "" "--variable=prefix")
find_program(GLIB_COMPILE_RESOURCES
             NAMES glib-compile-resources
             HINTS ${GLIB2_PREFIX})

if (NOT GLIB_COMPILE_RESOURCES)
message(FATAL "Could not find glib-compile-resources")
endif()

# Get the output file path
get_filename_component (resource_name ${resource_file} NAME_WE)
set (output_c "${output_dir}/${resource_name}-resources.c")
set (output_h "${output_dir}/${resource_name}-resources.h")
set (${output_source} ${output_c} PARENT_SCOPE)
set (${output_header} ${output_h} PARENT_SCOPE)

# Get the dependencies of the gresource
execute_process (
OUTPUT_VARIABLE _files
WORKING_DIRECTORY ${resource_dir}
COMMAND ${GLIB_COMPILE_RESOURCES} --generate-dependencies ${resource_file}
)

string (REPLACE "\n" ";" files ${_files})

set (depends "")
foreach (cur_file ${files})
list (APPEND depends "${resource_dir}/${cur_file}")
endforeach ()

# Command to compile the resources
add_custom_command (
OUTPUT ${output_c}
DEPENDS "${resource_dir}/${resource_file}" ${depends}
WORKING_DIRECTORY ${resource_dir}
COMMAND ${GLIB_COMPILE_RESOURCES} --generate-source --manual-register --target=${output_c} ${resource_file}
)

# Command to compile the resources
add_custom_command (
OUTPUT ${output_h}
DEPENDS "${resource_dir}/${resource_file}" ${depends}
WORKING_DIRECTORY ${resource_dir}
COMMAND ${GLIB_COMPILE_RESOURCES} --generate-header --manual-register --target=${output_h} ${resource_file}
)
endfunction ()