diff options
-rw-r--r-- | modules/FindQtDBus.cmake | 6 | ||||
-rw-r--r-- | modules/QtDBusMacros.cmake | 31 |
2 files changed, 37 insertions, 0 deletions
diff --git a/modules/FindQtDBus.cmake b/modules/FindQtDBus.cmake index 8a278786..f5e2e181 100644 --- a/modules/FindQtDBus.cmake +++ b/modules/FindQtDBus.cmake @@ -13,6 +13,12 @@ # QDBUS_ADD_INTERFACES(SRC_VAR file1.xml ... fileN.xml) # Generates interface code from the given XML files. # +# QDBUS_GENERATE_INTERFACE(file.h) +# Generates the XML interface description from the given header file. +# +# QDBUS_ADD_ADAPTOR(SRC_VAR file1.xml ... fileN.xml) +# Generates adaptor code from the given XML files. +# # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls diff --git a/modules/QtDBusMacros.cmake b/modules/QtDBusMacros.cmake index 5ee785db..a6e4221f 100644 --- a/modules/QtDBusMacros.cmake +++ b/modules/QtDBusMacros.cmake @@ -20,3 +20,34 @@ macro(qdbus_add_interfaces _sources) set(${_sources} ${${_sources}} ${_target_base}.cpp) endforeach (_i ${ARGN}) endmacro(qdbus_add_interfaces) + +macro(qdbus_generate_interface _header) + get_filename_component(_in_file ${_header} ABSOLUTE) + get_filename_component(_basename ${_header} NAME_WE) + set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml) + + add_custom_command(OUTPUT ${_target} + COMMAND ${QDBUS_CPP2XML_EXECUTABLE} + ARGS ${_in_file} > ${_target} + DEPENDS ${_in_file} + ) +endmacro(qdbus_generate_interface) + +macro(qdbus_add_adaptor _sources) + foreach (_i ${ARGN}) + get_filename_component(_xml_file ${_i} ABSOLUTE) + get_filename_component(_basename ${_i} NAME_WE) + set(_target_base ${CMAKE_CURRENT_BINARY_DIR}/${_basename}adaptor) + + add_custom_command(OUTPUT ${_target_base}.cpp ${_target_base}.h + COMMAND ${QDBUS_IDL2CPP_EXECUTABLE} + ARGS -m -a ${_basename}adaptor ${_xml_file} + DEPENDS ${_xml_file} + ) + + qt4_generate_moc(${_target_base}.h ${_target_base}.moc) + macro_add_file_dependencies(${_target_base}.h ${_target_base}.moc) + + set(${_sources} ${${_sources}} ${_target_base}.cpp) + endforeach (_i ${ARGN}) +endmacro(qdbus_add_adaptor) |