Warning, /frameworks/kdelibs4support/cmake/modules/NepomukAddOntologyClasses.cmake is written in an unsupported language. File is not indexed.
0001 # 0002 # Use the Nepomuk resource class generator to generate convinient Resource subclasses 0003 # from ontologies. 0004 # 0005 # Usage: 0006 # NEPOMUK_ADD_ONTOLOGY_CLASSES(<sources-var> 0007 # [FAST] 0008 # [ONTOLOGIES] <onto-file1> [<onto-file2> ...] 0009 # [CLASSES <class1> [<class2> ...]] 0010 # [VISIBILITY <visibility-name>] 0011 # ) 0012 # 0013 # If FAST is specified the rcgen parameter --fast will be used which results in resource classes 0014 # not based on Nepomuk::Resource but on a custom class which does not perform any checks and simply 0015 # writes the data to Nepomuk (hence the name fast). 0016 # 0017 # The optional CLASSES parameter allows to specify the classes to be generated (RDF URIs) in 0018 # case one does not want all classes in the ontologies to be generated. 0019 # 0020 # The optional VISIBILITY parameter can only be used in non-fast mode and allows to set the gcc visibility 0021 # to make the generated classes usable in a publically exported API. The <visibility-name> is used to create 0022 # the name of the export macro and the export include file. Thus, when using "VISIBILITY foobar" include 0023 # file "foobar_export.h" needs to define FOOBAR_EXPORT. 0024 # 0025 # Copyright (c) 2009 Sebastian Trueg <trueg@kde.org> 0026 # 0027 # Redistribution and use is allowed according to the terms of the BSD license. 0028 # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 0029 # 0030 macro(NEPOMUK_ADD_ONTOLOGY_CLASSES _sources) 0031 # extract arguments 0032 set(_current_arg_type "onto") 0033 foreach(_arg ${ARGN}) 0034 if(${_arg} STREQUAL "ONTOLOGIES") 0035 set(_current_arg_type "onto") 0036 elseif(${_arg} STREQUAL "VISIBILITY") 0037 set(_current_arg_type "visib") 0038 elseif(${_arg} STREQUAL "CLASSES") 0039 set(_current_arg_type "class") 0040 elseif(${_arg} STREQUAL "FAST") 0041 set(_fastmode "--fast") 0042 else(${_arg} STREQUAL "ONTOLOGIES") 0043 if(${_current_arg_type} STREQUAL "onto") 0044 list(APPEND _ontologies ${_arg}) 0045 get_filename_component(_filename ${_arg} NAME) 0046 list(APPEND _ontofilenames ${_filename}) 0047 elseif(${_current_arg_type} STREQUAL "class") 0048 list(APPEND _classes "--class" "${_arg}") 0049 else(${_current_arg_type} STREQUAL "onto") 0050 set(_visibility "--visibility" "${_arg}") 0051 endif(${_current_arg_type} STREQUAL "onto") 0052 endif(${_arg} STREQUAL "ONTOLOGIES") 0053 endforeach(_arg) 0054 0055 # find our helper program (first in the install dir, then everywhere) 0056 if(NOT WINCE) 0057 find_program(RCGEN nepomuk-rcgen PATHS ${KDE4_BIN_INSTALL_DIR} ${BIN_INSTALL_DIR} NO_DEFAULT_PATH) 0058 find_program(RCGEN nepomuk-rcgen) 0059 else(NOT WINCE) 0060 find_program(RCGEN nepomuk-rcgen PATHS ${HOST_BINDIR} NO_DEFAULT_PATH) 0061 endif(NOT WINCE) 0062 0063 if(NOT RCGEN) 0064 message(SEND_ERROR "Failed to find the Nepomuk source generator" ) 0065 else(NOT RCGEN) 0066 file(TO_NATIVE_PATH ${RCGEN} RCGEN) 0067 0068 # we generate the files in the current binary dir 0069 set(_targetdir ${CMAKE_CURRENT_BINARY_DIR}) 0070 0071 # generate the list of source and header files 0072 execute_process( 0073 COMMAND ${RCGEN} ${_fastmode} --listheaders --prefix ${_targetdir}/ ${_classes} ${_visibility} ${_ontologies} 0074 OUTPUT_VARIABLE _out_headers 0075 RESULT_VARIABLE rcgen_result 0076 ) 0077 if(NOT ${rcgen_result} EQUAL 0) 0078 message(SEND_ERROR "Running ${RCGEN} to generate list of headers failed with error code ${rcgen_result}") 0079 endif(NOT ${rcgen_result} EQUAL 0) 0080 0081 execute_process( 0082 COMMAND ${RCGEN} ${_fastmode} --listsources --prefix ${_targetdir}/ ${_classes} ${_visibility} ${_ontologies} 0083 OUTPUT_VARIABLE _out_sources 0084 RESULT_VARIABLE rcgen_result 0085 ) 0086 if(NOT ${rcgen_result} EQUAL 0) 0087 message(SEND_ERROR "Running ${RCGEN} to generate list of sources failed with error code ${rcgen_result}") 0088 endif(NOT ${rcgen_result} EQUAL 0) 0089 0090 add_custom_command(OUTPUT ${_out_headers} ${_out_sources} 0091 COMMAND ${RCGEN} ${_fastmode} --writeall --target ${_targetdir}/ ${_classes} ${_visibility} ${_ontologies} 0092 DEPENDS ${_ontologies} 0093 COMMENT "Generating ontology source files from ${_ontofilenames}" 0094 ) 0095 0096 # make sure the includes are found 0097 include_directories(${_targetdir}) 0098 0099 # finally append the source files to the source list 0100 list(APPEND ${_sources} ${_out_sources}) 0101 endif(NOT RCGEN) 0102 0103 # reset variable names used 0104 unset(_current_arg_type) 0105 unset(_arg) 0106 unset(_ontologies) 0107 unset(_ontofilenames) 0108 unset(_classes) 0109 unset(_visibility) 0110 unset(_fastmode) 0111 unset(_targetdir) 0112 unset(_out_headers) 0113 unset(_out_sources) 0114 unset(rcgen_result) 0115 endmacro(NEPOMUK_ADD_ONTOLOGY_CLASSES)