1
# Copyright (C) 2010 David Sansome <me@davidsansome.com>
2
cmake_minimum_required(VERSION 2.6)
4
cmake_policy(SET CMP0011 NEW)
7
find_program(GLIB_MKENUMS glib-mkenums)
8
find_program(GLIB_GENMARSHAL glib-genmarshal)
10
macro(add_glib_marshal outfiles name prefix otherinclude)
12
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
13
COMMAND ${GLIB_GENMARSHAL} --header "--prefix=${prefix}"
14
"${CMAKE_CURRENT_SOURCE_DIR}/${name}.list"
15
> "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
16
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.list"
19
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
20
COMMAND echo "\\#include \\\"${otherinclude}\\\"" > "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
21
COMMAND echo "\\#include \\\"glib-object.h\\\"" >> "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
22
COMMAND echo "\\#include \\\"${name}.h\\\"" >> "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
23
COMMAND ${GLIB_GENMARSHAL} --body "--prefix=${prefix}"
24
"${CMAKE_CURRENT_SOURCE_DIR}/${name}.list"
25
>> "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
26
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${name}.list"
27
"${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
29
list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c")
30
endmacro(add_glib_marshal)
32
macro(add_glib_enumtypes_t outfiles name htemplate ctemplate)
34
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
35
COMMAND ${GLIB_MKENUMS}
36
--template "${htemplate}"
37
${ARGN} > "${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
38
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
39
DEPENDS ${ARGN} "${htemplate}"
42
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
43
COMMAND ${GLIB_MKENUMS}
44
--template "${ctemplate}"
45
${ARGN} > "${CMAKE_CURRENT_BINARY_DIR}/${name}.c"
46
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
47
DEPENDS ${ARGN} ${ctemplate}
48
"${CMAKE_CURRENT_BINARY_DIR}/${name}.h"
50
list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c")
51
endmacro(add_glib_enumtypes_t)
53
macro(add_glib_enumtypes outfiles name includeguard)
54
set(htemplate "${CMAKE_CURRENT_BINARY_DIR}/${name}.h.template")
55
set(ctemplate "${CMAKE_CURRENT_BINARY_DIR}/${name}.c.template")
57
# Write the .h template
59
OUTPUT ${htemplate} ${ctemplate}
60
COMMAND ${CMAKE_COMMAND}
61
"-Dctemplate=${ctemplate}"
62
"-Dhtemplate=${htemplate}"
64
"-Dincludeguard=${includeguard}"
65
"\"-Dheaders=${ARGN}\""
66
-P "${CMAKE_SOURCE_DIR}/CMake/MakeGLibEnumTemplates.cmake"
67
DEPENDS "${CMAKE_SOURCE_DIR}/CMake/MakeGLibEnumTemplates.cmake" ${headers}
70
add_glib_enumtypes_t(${outfiles} ${name} ${htemplate} ${ctemplate} ${ARGN})
71
endmacro(add_glib_enumtypes)