~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/poppler/cmake/modules/GObjectIntrospectionMacros.cmake

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2010, Pino Toscano, <pino@kde.org>
 
2
#
 
3
# Redistribution and use is allowed according to the terms of the BSD license.
 
4
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
5
 
 
6
macro(_gir_list_prefix _outvar _listvar _prefix)
 
7
  set(${_outvar})
 
8
  foreach(_item IN LISTS ${_listvar})
 
9
    list(APPEND ${_outvar} ${_prefix}${_item})
 
10
  endforeach()
 
11
endmacro(_gir_list_prefix)
 
12
 
 
13
macro(gir_add_introspections introspections_girs)
 
14
 
 
15
  set(_gir_girs)
 
16
  set(_gir_typelibs)
 
17
 
 
18
  foreach(gir IN LISTS ${introspections_girs})
 
19
 
 
20
    set(_gir_name "${gir}")
 
21
 
 
22
    ## Transform the gir filename to something which can reference through a variable
 
23
    ## without automake/make complaining, eg Gtk-2.0.gir -> Gtk_2_0_gir
 
24
    string(REPLACE "-" "_" _gir_name "${_gir_name}")
 
25
    string(REPLACE "." "_" _gir_name "${_gir_name}")
 
26
 
 
27
    # Namespace and Version is either fetched from the gir filename
 
28
    # or the _NAMESPACE/_VERSION variable combo
 
29
    set(_gir_namespace "${${_gir_name}_NAMESPACE}")
 
30
    if (_gir_namespace STREQUAL "")
 
31
      string(REGEX REPLACE "([^-]+)-.*" "\\1" _gir_namespace "${gir}")
 
32
    endif ()
 
33
    set(_gir_version "${${_gir_name}_VERSION}")
 
34
    if (_gir_version STREQUAL "")
 
35
      string(REGEX REPLACE ".*-([^-]+).gir" "\\1" _gir_version "${gir}")
 
36
    endif ()
 
37
 
 
38
    # _PROGRAM is an optional variable which needs it's own --program argument
 
39
    set(_gir_program "${${_gir_name}_PROGRAM}")
 
40
    if (NOT _gir_program STREQUAL "")
 
41
      set(_gir_program "--program=${_gir_program}")
 
42
    endif ()
 
43
 
 
44
    # Variables which provides a list of things
 
45
    _gir_list_prefix(_gir_libraries ${_gir_name}_LIBS "--library=")
 
46
    _gir_list_prefix(_gir_packages ${_gir_name}_PACKAGES "--pkg=")
 
47
    _gir_list_prefix(_gir_includes ${_gir_name}_INCLUDES "--include=")
 
48
 
 
49
    # Reuse the LIBTOOL variable from by automake if it's set
 
50
    set(_gir_libtool "--no-libtool")
 
51
 
 
52
    add_custom_command(
 
53
      COMMAND ${INTROSPECTION_SCANNER}
 
54
              ${INTROSPECTION_SCANNER_ARGS}
 
55
              --namespace=${_gir_namespace}
 
56
              --nsversion=${_gir_version}
 
57
              ${_gir_libtool}
 
58
              ${_gir_program}
 
59
              ${_gir_libraries}
 
60
              ${_gir_packages}
 
61
              ${_gir_includes}
 
62
              ${${_gir_name}_SCANNERFLAGS}
 
63
              ${${_gir_name}_CFLAGS}
 
64
              ${${_gir_name}_FILES}
 
65
              --output ${CMAKE_CURRENT_BINARY_DIR}/${gir}
 
66
      DEPENDS ${${_gir_name}_FILES}
 
67
              ${${_gir_name}_LIBS}
 
68
      OUTPUT ${gir}
 
69
      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 
70
      VERBATIM
 
71
    )
 
72
    list(APPEND _gir_girs ${CMAKE_CURRENT_BINARY_DIR}/${gir})
 
73
    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${gir} DESTINATION share/gir-1.0)
 
74
 
 
75
    string(REPLACE ".gir" ".typelib" _typelib "${gir}")
 
76
    add_custom_command(
 
77
      COMMAND ${INTROSPECTION_COMPILER}
 
78
              ${INTROSPECTION_COMPILER_ARGS}
 
79
              --includedir=.
 
80
              ${CMAKE_CURRENT_BINARY_DIR}/${gir}
 
81
              -o ${CMAKE_CURRENT_BINARY_DIR}/${_typelib}
 
82
      DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${gir}
 
83
      OUTPUT ${_typelib}
 
84
      WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
 
85
    )
 
86
    list(APPEND _gir_typelibs ${CMAKE_CURRENT_BINARY_DIR}/${_typelib})
 
87
    install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_typelib} DESTINATION lib${LIB_SUFFIX}/girepository-1.0)
 
88
 
 
89
  endforeach()
 
90
 
 
91
  add_custom_target(gir-girs ALL DEPENDS ${_gir_girs})
 
92
  add_custom_target(gir-typelibs ALL DEPENDS ${_gir_typelibs})
 
93
 
 
94
endmacro(gir_add_introspections)