~decathorpe/slingshot/unmark-executable-code

« back to all changes in this revision

Viewing changes to cmake/GResource.cmake

  • Committer: Corentin Noël
  • Date: 2017-01-15 22:59:38 UTC
  • Revision ID: corentin@elementary.io-20170115225938-geipgmbuty7yexb3
Add missing GResource.cmake

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
#    Copyright (C) 2013 Venom authors and contributors
 
3
#
 
4
#    This file is part of Venom.
 
5
#
 
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.
 
10
#
 
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.
 
15
#
 
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/>.
 
18
#
 
19
 
 
20
FIND_PROGRAM(GLIB_COMPILE_RESOURCES_EXECUTABLE NAMES glib-compile-resources)
 
21
MARK_AS_ADVANCED(GLIB_COMPILE_RESOURCES_EXECUTABLE)
 
22
 
 
23
INCLUDE(CMakeParseArguments)
 
24
 
 
25
FUNCTION(GLIB_COMPILE_RESOURCES output)
 
26
  CMAKE_PARSE_ARGUMENTS(ARGS "" "SOURCE" "" ${ARGN})
 
27
  SET(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
 
28
  SET(out_files "")
 
29
 
 
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}")
 
38
 
 
39
    #FIXME implicit depends currently not working
 
40
    EXECUTE_PROCESS(
 
41
      COMMAND
 
42
        ${GLIB_COMPILE_RESOURCES_EXECUTABLE}
 
43
          "--generate-dependencies"
 
44
          ${in_file}
 
45
      WORKING_DIRECTORY ${WORKING_DIR}
 
46
      OUTPUT_VARIABLE in_file_dep
 
47
    )
 
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})
 
53
    ADD_CUSTOM_COMMAND(
 
54
      OUTPUT ${out_file}
 
55
      WORKING_DIRECTORY ${WORKING_DIR}
 
56
      COMMAND
 
57
        ${GLIB_COMPILE_RESOURCES_EXECUTABLE}
 
58
      ARGS
 
59
        "--generate-source"
 
60
        "--target=${out_file}"
 
61
        ${in_file}
 
62
      DEPENDS
 
63
        ${in_file};${in_file_dep_path}
 
64
    )
 
65
  ENDFOREACH(src ${ARGS_SOURCES} ${ARGS_UNPARSED_ARGUMENTS})
 
66
  SET(${output} ${out_files} PARENT_SCOPE)
 
67
ENDFUNCTION(GLIB_COMPILE_RESOURCES)