~midori/midori/trunk

« back to all changes in this revision

Viewing changes to cmake/GLibHelpers.cmake

  • Committer: Christian Dywan
  • Date: 2013-08-18 00:47:45 UTC
  • mto: This revision was merged to the branch mainline in revision 6370.
  • Revision ID: christian.dywan@canonical.com-20130818004745-7yo9c8utphdhjt1k
Initial minimal CMake build setup

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2010 David Sansome <me@davidsansome.com>
 
2
cmake_minimum_required(VERSION 2.6)
 
3
if(POLICY CMP0011)
 
4
  cmake_policy(SET CMP0011 NEW)
 
5
endif(POLICY CMP0011)
 
6
 
 
7
find_program(GLIB_MKENUMS glib-mkenums)
 
8
find_program(GLIB_GENMARSHAL glib-genmarshal)
 
9
 
 
10
macro(add_glib_marshal outfiles name prefix otherinclude)
 
11
  add_custom_command(
 
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"
 
17
  )
 
18
  add_custom_command(
 
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"
 
28
  )
 
29
  list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c")
 
30
endmacro(add_glib_marshal)
 
31
 
 
32
macro(add_glib_enumtypes_t outfiles name htemplate ctemplate)
 
33
  add_custom_command(
 
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}"
 
40
  )
 
41
  add_custom_command(
 
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"
 
49
  )
 
50
  list(APPEND ${outfiles} "${CMAKE_CURRENT_BINARY_DIR}/${name}.c")
 
51
endmacro(add_glib_enumtypes_t)
 
52
 
 
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")
 
56
 
 
57
  # Write the .h template
 
58
  add_custom_command(
 
59
    OUTPUT ${htemplate} ${ctemplate}
 
60
    COMMAND ${CMAKE_COMMAND}
 
61
        "-Dctemplate=${ctemplate}"
 
62
        "-Dhtemplate=${htemplate}"
 
63
        "-Dname=${name}"
 
64
        "-Dincludeguard=${includeguard}"
 
65
        "\"-Dheaders=${ARGN}\""
 
66
        -P "${CMAKE_SOURCE_DIR}/CMake/MakeGLibEnumTemplates.cmake"
 
67
    DEPENDS "${CMAKE_SOURCE_DIR}/CMake/MakeGLibEnumTemplates.cmake" ${headers}
 
68
  )
 
69
 
 
70
  add_glib_enumtypes_t(${outfiles} ${name} ${htemplate} ${ctemplate} ${ARGN})
 
71
endmacro(add_glib_enumtypes)