From 3b68688a4a9b55b52a218550a6581693fce8d5a3 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Thu, 3 Dec 2009 21:36:28 +0000 Subject: -move this file also to cmake/modules/ where all the other installed files are Alex CCMAIL: trueg@kde.org svn path=/trunk/KDE/kdelibs/; revision=1058059 --- modules/NepomukAddOntologyClasses.cmake | 98 +++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 modules/NepomukAddOntologyClasses.cmake (limited to 'modules/NepomukAddOntologyClasses.cmake') diff --git a/modules/NepomukAddOntologyClasses.cmake b/modules/NepomukAddOntologyClasses.cmake new file mode 100644 index 00000000..687db6ef --- /dev/null +++ b/modules/NepomukAddOntologyClasses.cmake @@ -0,0 +1,98 @@ +# +# Use the Nepomuk resource class generator to generate convinient Resource subclasses +# from ontologies. +# +# Usage: +# NEPOMUK_ADD_ONTOLOGY_CLASSES( +# [FAST] +# [ONTOLOGIES] [ ...] +# [CLASSES [ ...]] +# [VISIBILITY ] +# ) +# +# If FAST is specified the rcgen parameter --fast will be used which results in resource classes +# not based on Nepomuk::Resource but on a custom class which does not perform any checks and simply +# writes the data to Nepomuk (hence the name fast). +# +# The optional CLASSES parameter allows to specify the classes to be generated (RDF URIs) in +# case one does not want all classes in the ontologies to be generated. +# +# The optional VISIBILITY parameter can only be used in non-fast mode and allows to set the gcc visibility +# to make the generated classes usable in a publically exported API. The is used to create +# the name of the export macro and the export include file. Thus, when using "VISIBILITY foobar" include +# file "foobar_export.h" needs to define FOOBAR_EXPORT. +# +# Copyright (c) 2009 Sebastian Trueg +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# +macro(NEPOMUK_ADD_ONTOLOGY_CLASSES _sources) + # extract arguments + set(_current_arg_type "onto") + foreach(_arg ${ARGN}) + if(${_arg} STREQUAL "ONTOLOGIES") + set(_current_arg_type "onto") + elseif(${_arg} STREQUAL "VISIBILITY") + set(_current_arg_type "visib") + elseif(${_arg} STREQUAL "CLASSES") + set(_current_arg_type "class") + elseif(${_arg} STREQUAL "FAST") + set(_fastmode "--fast") + else(${_arg} STREQUAL "ONTOLOGIES") + if(${_current_arg_type} STREQUAL "onto") + list(APPEND _ontologies ${_arg}) + get_filename_component(_filename ${_arg} NAME) + list(APPEND _ontofilenames ${_filename}) + elseif(${_current_arg_type} STREQUAL "class") + list(APPEND _classes "--class" "${_arg}") + else(${_current_arg_type} STREQUAL "onto") + set(_visibility "--visibility" "${_arg}") + endif(${_current_arg_type} STREQUAL "onto") + endif(${_arg} STREQUAL "ONTOLOGIES") + endforeach(_arg) + + # find our helper program (first in the install dir, then everywhere) + find_program(RCGEN nepomuk-rcgen PATHS ${KDE4_BIN_INSTALL_DIR} ${BIN_INSTALL_DIR} NO_DEFAULT_PATH) + find_program(RCGEN nepomuk-rcgen) + + if(NOT RCGEN) + message(SEND_ERROR "Failed to find the Nepomuk source generator" ) + else(NOT RCGEN) + FILE(TO_NATIVE_PATH ${RCGEN} RCGEN) + + # we generate the files in the current binary dir + set(_targetdir ${CMAKE_CURRENT_BINARY_DIR}) + + # generate the list of source and header files + execute_process( + COMMAND ${RCGEN} ${_fastmode} --listheaders --prefix ${_targetdir}/ ${_classes} ${_visibility} ${_ontologies} + OUTPUT_VARIABLE _out_headers + RESULT_VARIABLE rcgen_result + ) + if(NOT ${rcgen_result} EQUAL 0) + message(SEND_ERROR "Running ${RCGEN} to generate list of headers failed with error code ${rcgen_result}") + endif(NOT ${rcgen_result} EQUAL 0) + + execute_process( + COMMAND ${RCGEN} ${_fastmode} --listsources --prefix ${_targetdir}/ ${_classes} ${_visibility} ${_ontologies} + OUTPUT_VARIABLE _out_sources + RESULT_VARIABLE rcgen_result + ) + if(NOT ${rcgen_result} EQUAL 0) + message(SEND_ERROR "Running ${RCGEN} to generate list of sources failed with error code ${rcgen_result}") + endif(NOT ${rcgen_result} EQUAL 0) + + add_custom_command(OUTPUT ${_out_headers} ${_out_sources} + COMMAND ${RCGEN} ${_fastmode} --writeall --target ${_targetdir}/ ${_classes} ${_visibility} ${_ontologies} + DEPENDS ${_ontologies} + COMMENT "Generating ontology source files from ${_ontofilenames}" + ) + + # make sure the includes are found + include_directories(${_targetdir}) + + # finally append the source files to the source list + list(APPEND ${_sources} ${_out_sources}) + endif(NOT RCGEN) +endmacro(NEPOMUK_ADD_ONTOLOGY_CLASSES) -- cgit v1.2.1 From 773aa770c5f9d5900b9f71b0b204afd20b1b1ced Mon Sep 17 00:00:00 2001 From: Romain Pokrzywka Date: Wed, 30 Dec 2009 09:32:20 +0000 Subject: jom parses the '#' from the class uri as the start of a comment so we must escape it svn path=/trunk/KDE/kdelibs/; revision=1067673 --- modules/NepomukAddOntologyClasses.cmake | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'modules/NepomukAddOntologyClasses.cmake') diff --git a/modules/NepomukAddOntologyClasses.cmake b/modules/NepomukAddOntologyClasses.cmake index 687db6ef..7245e51b 100644 --- a/modules/NepomukAddOntologyClasses.cmake +++ b/modules/NepomukAddOntologyClasses.cmake @@ -83,10 +83,20 @@ macro(NEPOMUK_ADD_ONTOLOGY_CLASSES _sources) message(SEND_ERROR "Running ${RCGEN} to generate list of sources failed with error code ${rcgen_result}") endif(NOT ${rcgen_result} EQUAL 0) + # jom parses the '#' from the class uri as the start of a comment so we must escape it + if(MSVC) + foreach(_class IN LISTS _classes) + string(REPLACE "#" "^#" _class ${_class}) + list(REMOVE_AT _classes 0) + list(APPEND _classes ${_class}) + endforeach(_class) + endif(MSVC) + add_custom_command(OUTPUT ${_out_headers} ${_out_sources} COMMAND ${RCGEN} ${_fastmode} --writeall --target ${_targetdir}/ ${_classes} ${_visibility} ${_ontologies} DEPENDS ${_ontologies} COMMENT "Generating ontology source files from ${_ontofilenames}" + VERBATIM ) # make sure the includes are found -- cgit v1.2.1 From 1b03544444fb469a8726b846f23db408c6da6549 Mon Sep 17 00:00:00 2001 From: Romain Pokrzywka Date: Wed, 30 Dec 2009 09:55:53 +0000 Subject: hmm, actually that change breaks nmake, so revert it. It's a bug that has to be fixed in jom directly. svn path=/trunk/KDE/kdelibs/; revision=1067674 --- modules/NepomukAddOntologyClasses.cmake | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'modules/NepomukAddOntologyClasses.cmake') diff --git a/modules/NepomukAddOntologyClasses.cmake b/modules/NepomukAddOntologyClasses.cmake index 7245e51b..687db6ef 100644 --- a/modules/NepomukAddOntologyClasses.cmake +++ b/modules/NepomukAddOntologyClasses.cmake @@ -83,20 +83,10 @@ macro(NEPOMUK_ADD_ONTOLOGY_CLASSES _sources) message(SEND_ERROR "Running ${RCGEN} to generate list of sources failed with error code ${rcgen_result}") endif(NOT ${rcgen_result} EQUAL 0) - # jom parses the '#' from the class uri as the start of a comment so we must escape it - if(MSVC) - foreach(_class IN LISTS _classes) - string(REPLACE "#" "^#" _class ${_class}) - list(REMOVE_AT _classes 0) - list(APPEND _classes ${_class}) - endforeach(_class) - endif(MSVC) - add_custom_command(OUTPUT ${_out_headers} ${_out_sources} COMMAND ${RCGEN} ${_fastmode} --writeall --target ${_targetdir}/ ${_classes} ${_visibility} ${_ontologies} DEPENDS ${_ontologies} COMMENT "Generating ontology source files from ${_ontofilenames}" - VERBATIM ) # make sure the includes are found -- cgit v1.2.1 From bd1362891b49d7477faf5b06a2b821adb4f90809 Mon Sep 17 00:00:00 2001 From: Andreas Holzammer Date: Tue, 13 Jul 2010 09:57:04 +0000 Subject: - changed findscript for wince to find the host generator svn path=/trunk/KDE/kdelibs/; revision=1149380 --- modules/NepomukAddOntologyClasses.cmake | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'modules/NepomukAddOntologyClasses.cmake') diff --git a/modules/NepomukAddOntologyClasses.cmake b/modules/NepomukAddOntologyClasses.cmake index 687db6ef..68a2faee 100644 --- a/modules/NepomukAddOntologyClasses.cmake +++ b/modules/NepomukAddOntologyClasses.cmake @@ -53,8 +53,12 @@ macro(NEPOMUK_ADD_ONTOLOGY_CLASSES _sources) endforeach(_arg) # find our helper program (first in the install dir, then everywhere) + if(NOT WINCE) find_program(RCGEN nepomuk-rcgen PATHS ${KDE4_BIN_INSTALL_DIR} ${BIN_INSTALL_DIR} NO_DEFAULT_PATH) find_program(RCGEN nepomuk-rcgen) + else(NOT WINCE) + find_program(RCGEN nepomuk-rcgen PATHS ${HOST_BINDIR} NO_DEFAULT_PATH) + endif(NOT WINCE) if(NOT RCGEN) message(SEND_ERROR "Failed to find the Nepomuk source generator" ) -- cgit v1.2.1 From 0c17e8963e4a6e144561b4c541d85986f029abba Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Tue, 24 Aug 2010 19:54:56 +0000 Subject: -fix indentation, all lower-case Alex svn path=/trunk/KDE/kdelibs/; revision=1167511 --- modules/NepomukAddOntologyClasses.cmake | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'modules/NepomukAddOntologyClasses.cmake') diff --git a/modules/NepomukAddOntologyClasses.cmake b/modules/NepomukAddOntologyClasses.cmake index 68a2faee..6a49a5a9 100644 --- a/modules/NepomukAddOntologyClasses.cmake +++ b/modules/NepomukAddOntologyClasses.cmake @@ -54,20 +54,20 @@ macro(NEPOMUK_ADD_ONTOLOGY_CLASSES _sources) # find our helper program (first in the install dir, then everywhere) if(NOT WINCE) - find_program(RCGEN nepomuk-rcgen PATHS ${KDE4_BIN_INSTALL_DIR} ${BIN_INSTALL_DIR} NO_DEFAULT_PATH) - find_program(RCGEN nepomuk-rcgen) + find_program(RCGEN nepomuk-rcgen PATHS ${KDE4_BIN_INSTALL_DIR} ${BIN_INSTALL_DIR} NO_DEFAULT_PATH) + find_program(RCGEN nepomuk-rcgen) else(NOT WINCE) - find_program(RCGEN nepomuk-rcgen PATHS ${HOST_BINDIR} NO_DEFAULT_PATH) + find_program(RCGEN nepomuk-rcgen PATHS ${HOST_BINDIR} NO_DEFAULT_PATH) endif(NOT WINCE) if(NOT RCGEN) message(SEND_ERROR "Failed to find the Nepomuk source generator" ) else(NOT RCGEN) - FILE(TO_NATIVE_PATH ${RCGEN} RCGEN) + file(TO_NATIVE_PATH ${RCGEN} RCGEN) # we generate the files in the current binary dir set(_targetdir ${CMAKE_CURRENT_BINARY_DIR}) - + # generate the list of source and header files execute_process( COMMAND ${RCGEN} ${_fastmode} --listheaders --prefix ${_targetdir}/ ${_classes} ${_visibility} ${_ontologies} @@ -86,7 +86,7 @@ macro(NEPOMUK_ADD_ONTOLOGY_CLASSES _sources) if(NOT ${rcgen_result} EQUAL 0) message(SEND_ERROR "Running ${RCGEN} to generate list of sources failed with error code ${rcgen_result}") endif(NOT ${rcgen_result} EQUAL 0) - + add_custom_command(OUTPUT ${_out_headers} ${_out_sources} COMMAND ${RCGEN} ${_fastmode} --writeall --target ${_targetdir}/ ${_classes} ${_visibility} ${_ontologies} DEPENDS ${_ontologies} -- cgit v1.2.1 From 688ff8be0ef694a064ebf70a9849a784614d6c21 Mon Sep 17 00:00:00 2001 From: Sebastian Trueg Date: Sun, 21 Nov 2010 19:08:58 +0000 Subject: Unset all temp variables to not pollute the global "namespace". svn path=/trunk/KDE/kdelibs/; revision=1199385 --- modules/NepomukAddOntologyClasses.cmake | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'modules/NepomukAddOntologyClasses.cmake') diff --git a/modules/NepomukAddOntologyClasses.cmake b/modules/NepomukAddOntologyClasses.cmake index 6a49a5a9..a2bdd5bb 100644 --- a/modules/NepomukAddOntologyClasses.cmake +++ b/modules/NepomukAddOntologyClasses.cmake @@ -99,4 +99,17 @@ macro(NEPOMUK_ADD_ONTOLOGY_CLASSES _sources) # finally append the source files to the source list list(APPEND ${_sources} ${_out_sources}) endif(NOT RCGEN) + + # reset variable names used + unset(_current_arg_type) + unset(_arg) + unset(_ontologies) + unset(_ontofilenames) + unset(_classes) + unset(_visibility) + unset(_fastmode) + unset(_targetdir) + unset(_out_headers) + unset(_out_sources) + unset(rcgen_result) endmacro(NEPOMUK_ADD_ONTOLOGY_CLASSES) -- cgit v1.2.1