2
# Copyright (C) 2013 Venom authors and contributors
4
# This file is part of Venom.
6
# Venom is free software: you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation, either version 3 of the License, or
9
# (at your option) any later version.
11
# Venom is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
16
# You should have received a copy of the GNU General Public License
17
# along with Venom. If not, see <http://www.gnu.org/licenses/>.
20
FIND_PROGRAM(GLIB_COMPILE_RESOURCES_EXECUTABLE NAMES glib-compile-resources)
21
MARK_AS_ADVANCED(GLIB_COMPILE_RESOURCES_EXECUTABLE)
23
INCLUDE(CMakeParseArguments)
25
FUNCTION(GLIB_COMPILE_RESOURCES output)
26
CMAKE_PARSE_ARGUMENTS(ARGS "" "SOURCE" "" ${ARGN})
27
SET(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
30
FOREACH(src ${ARGS_SOURCE} ${ARGS_UNPARSED_ARGUMENTS})
31
SET(in_file "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
32
GET_FILENAME_COMPONENT(WORKING_DIR ${in_file} PATH)
33
STRING(REPLACE ".xml" ".c" src ${src})
34
SET(out_file "${DIRECTORY}/${src}")
35
GET_FILENAME_COMPONENT(OUPUT_DIR ${out_file} PATH)
36
FILE(MAKE_DIRECTORY ${OUPUT_DIR})
37
LIST(APPEND out_files "${DIRECTORY}/${src}")
39
#FIXME implicit depends currently not working
42
${GLIB_COMPILE_RESOURCES_EXECUTABLE}
43
"--generate-dependencies"
45
WORKING_DIRECTORY ${WORKING_DIR}
46
OUTPUT_VARIABLE in_file_dep
48
STRING(REGEX REPLACE "(\r?\n)" ";" in_file_dep "${in_file_dep}")
49
SET(in_file_dep_path "")
50
FOREACH(dep ${in_file_dep})
51
LIST(APPEND in_file_dep_path "${WORKING_DIR}/${dep}")
52
ENDFOREACH(dep ${in_file_dep})
55
WORKING_DIRECTORY ${WORKING_DIR}
57
${GLIB_COMPILE_RESOURCES_EXECUTABLE}
60
"--target=${out_file}"
63
${in_file};${in_file_dep_path}
65
ENDFOREACH(src ${ARGS_SOURCES} ${ARGS_UNPARSED_ARGUMENTS})
66
SET(${output} ${out_files} PARENT_SCOPE)
67
ENDFUNCTION(GLIB_COMPILE_RESOURCES)