aboutsummaryrefslogtreecommitdiff
path: root/modules/NepomukMacros.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'modules/NepomukMacros.cmake')
-rw-r--r--modules/NepomukMacros.cmake64
1 files changed, 43 insertions, 21 deletions
diff --git a/modules/NepomukMacros.cmake b/modules/NepomukMacros.cmake
index 9476cf64..18aeca27 100644
--- a/modules/NepomukMacros.cmake
+++ b/modules/NepomukMacros.cmake
@@ -18,32 +18,54 @@
#
# 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
+#
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 ${BIN_INSTALL_DIR})
+
if(NOT RCGEN)
- message( FATAL_ERROR "Failed to find the KMetaData source generator" )
- endif(NOT RCGEN)
- FILE(TO_NATIVE_PATH ${RCGEN} RCGEN)
+ message(STATUS "Failed to find the Nepomuk source generator" )
- execute_process(
- COMMAND ${RCGEN} --listheaders --prefix ${targetdir}/ --ontologies ${ontofile}
- OUTPUT_VARIABLE ${out_headers}
- )
-
- 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}
- )
+ 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)