File: NepomukMacros.cmake

package info (click to toggle)
kde4libs 4%3A4.14.2-5
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 82,316 kB
  • sloc: cpp: 761,810; xml: 12,344; ansic: 6,295; java: 4,060; perl: 2,938; yacc: 2,507; python: 1,207; sh: 1,179; ruby: 337; lex: 278; makefile: 29
file content (67 lines) | stat: -rw-r--r-- 2,176 bytes parent folder | download | duplicates (13)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# This file contains the following macros:
#
# NEPOMUK_GENERATE_FROM_ONTOLOGY
# Parameters:
#   ontofile     - Path to the NRL ontology defining the resources to be generated.
#   targetdir    - Folder to which the generated sources should be written.
#   out_headers  - Variable which will be filled with the names of all generated headers.
#   out_sources  - Variable which will be filled with the names of all generated sources.
#   out_includes - Variable which will be filled with complete include statements of all 
#                  generated resource classes.
#
# In addition to the parameters an arbitrary number of template filenames can be set as arguments
#
# In case of success NEPOMUK_RESOURCES_GENERATED is true, otherwise false

# (C) 2007 Sebastian Trueg <trueg@kde.org>


macro(NEPOMUK_GENERATE_FROM_ONTOLOGY ontofile targetdir out_headers out_sources out_includes)

  # init
  set(NEPOMUK_RESOURCES_GENERATED false)

  find_program(RCGEN nepomuk-rcgen PATHS ${KDE4_BIN_INSTALL_DIR} ${BIN_INSTALL_DIR} NO_DEFAULT_PATH)

  if(NOT RCGEN)

    message(STATUS "Failed to find the Nepomuk source generator" )

  else(NOT RCGEN)

    FILE(TO_NATIVE_PATH ${RCGEN} RCGEN)

    execute_process(
      COMMAND ${RCGEN} --listheaders --prefix ${targetdir}/ --ontologies ${ontofile}
      OUTPUT_VARIABLE ${out_headers}
      RESULT_VARIABLE rcgen_result
      )

    # If the first call succeeds it is very very likely that the rest will, too
    if(${rcgen_result} EQUAL 0)

      execute_process(
        COMMAND ${RCGEN} --listsources --prefix ${targetdir}/ --ontologies ${ontofile}
        OUTPUT_VARIABLE ${out_sources}
        )
      
      execute_process(
        COMMAND ${RCGEN} --listincludes --ontologies ${ontofile}
        OUTPUT_VARIABLE ${out_includes}
        )

      execute_process(
        COMMAND ${RCGEN} --writeall --templates ${ARGN} --target ${targetdir}/ --ontologies ${ontofile}
        )

      set(NEPOMUK_RESOURCES_GENERATED true)

    else(${rcgen_result} EQUAL 0)

      message(STATUS "Failed to generate Nepomuk resource classes.")

    endif(${rcgen_result} EQUAL 0)

  endif(NOT RCGEN)
  
endmacro(NEPOMUK_GENERATE_FROM_ONTOLOGY)