1macro(add_gschema_targets _gschema_INPUTS) 2 set(_gschema_OUTPUTS "") 3 set(local_depends ${gschema_depends}) 4 foreach(file ${_gschema_INPUTS}) 5 6 set(_OUTPUT_FILE ${DATADIR_BUILD}/glib-2.0/schemas/${file}) 7 configure_file(${file}.in ${_OUTPUT_FILE} @ONLY) 8 list(APPEND _gschema_OUTPUTS ${_OUTPUT_FILE}) 9 10 string(REPLACE ".xml" ".valid" file_no_xml ${file}) 11 set(_VALID_FILE ${CMAKE_CURRENT_BINARY_DIR}/${file_no_xml}) 12 list(APPEND _gschema_VALIDS ${_VALID_FILE}) 13 add_custom_command( 14 OUTPUT ${_VALID_FILE} 15 COMMAND ${CMAKE_COMMAND} -E env 16 ${GLIB_COMPILE_SCHEMAS} --strict --dry-run --schema-file=${_OUTPUT_FILE} 17 COMMAND ${CMAKE_COMMAND} -E touch ${_VALID_FILE} 18 DEPENDS ${_OUTPUT_FILE} 19 ) 20 add_custom_target(${file_no_xml}-target DEPENDS ${_VALID_FILE}) 21 22 # Add both a target and a file level dependency for the valid target/file 23 # to the gschemas.compiled target (local_depends will be propagated to that target) 24 # The target level one is to ensure a link between two targets in different directories (required for the make build chain) 25 # The file level one is to ensure gschemas.compiled will be rebuilt if any of the 26 # dependencies changes. 27 list(APPEND local_depends ${file_no_xml}-target ${_VALID_FILE}) 28 endforeach(file) 29 30 set(gschema_depends ${local_depends} CACHE INTERNAL "gschemas.compiled dependencies") 31 32 install(FILES ${_gschema_OUTPUTS} DESTINATION share/glib-2.0/schemas) 33 34endmacro() 35