File: GncAddGSchemaTargets.cmake

package info (click to toggle)
gnucash 1%3A3.4-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 111,864 kB
  • sloc: ansic: 327,376; cpp: 71,145; lisp: 47,888; javascript: 23,306; python: 8,063; xml: 4,622; perl: 524; sh: 223; makefile: 55
file content (38 lines) | stat: -rw-r--r-- 1,622 bytes parent folder | download
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
macro(add_gschema_targets _gschema_INPUTS)
  set(_gschema_OUTPUTS "")
  set(local_depends ${gschema_depends})
  set(CMAKE_COMMAND_TMP "")
  if (${CMAKE_VERSION} VERSION_GREATER 3.1)
    set(CMAKE_COMMAND_TMP ${CMAKE_COMMAND} -E env)
  endif()
  foreach(file ${_gschema_INPUTS})

    set(_OUTPUT_FILE ${DATADIR_BUILD}/glib-2.0/schemas/${file})
    configure_file(${file}.in ${_OUTPUT_FILE} @ONLY)
    list(APPEND _gschema_OUTPUTS ${_OUTPUT_FILE})

    string(REPLACE ".xml" ".valid" file_no_xml ${file})
    set(_VALID_FILE ${CMAKE_CURRENT_BINARY_DIR}/${file_no_xml})
    list(APPEND _gschema_VALIDS ${_VALID_FILE})
    add_custom_command(
        OUTPUT ${_VALID_FILE}
        COMMAND ${CMAKE_COMMAND_TMP}
          ${GLIB_COMPILE_SCHEMAS} --strict --dry-run --schema-file=${_OUTPUT_FILE}
        COMMAND ${CMAKE_COMMAND} -E touch ${_VALID_FILE}
        DEPENDS ${_OUTPUT_FILE}
    )
    add_custom_target(${file_no_xml}-target DEPENDS ${_VALID_FILE})

    # Add both a target and a file level dependency for the valid target/file
    # to the gschemas.compiled target (local_depends will be propagated to that target)
    # The target level one is to ensure a link between two targets in different directories (required for the make build chain)
    # The file level one is to ensure gschemas.compiled will be rebuilt if any of the
    # dependencies changes.
    list(APPEND local_depends ${file_no_xml}-target ${_VALID_FILE})
  endforeach(file)

  set(gschema_depends ${local_depends} CACHE INTERNAL "gschemas.compiled dependencies")

  install(FILES ${_gschema_OUTPUTS} DESTINATION share/glib-2.0/schemas)

endmacro()