# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#=============================================================================
-MACRO (QT5_EXTRACT_OPTIONS _qt5_files _qt5_options)
- SET(${_qt5_files})
- SET(${_qt5_options})
- SET(_QT5_DOING_OPTIONS FALSE)
- FOREACH(_currentArg ${ARGN})
- IF ("${_currentArg}" STREQUAL "OPTIONS")
- SET(_QT5_DOING_OPTIONS TRUE)
- ELSE ("${_currentArg}" STREQUAL "OPTIONS")
- IF(_QT5_DOING_OPTIONS)
- LIST(APPEND ${_qt5_options} "${_currentArg}")
- ELSE(_QT5_DOING_OPTIONS)
- LIST(APPEND ${_qt5_files} "${_currentArg}")
- ENDIF(_QT5_DOING_OPTIONS)
- ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
- ENDFOREACH(_currentArg)
-ENDMACRO (QT5_EXTRACT_OPTIONS)
+macro(QT5_EXTRACT_OPTIONS _qt5_files _qt5_options)
+ set(${_qt5_files})
+ set(${_qt5_options})
+ set(_QT5_DOING_OPTIONS FALSE)
+ foreach(_currentArg ${ARGN})
+ if("${_currentArg}" STREQUAL "OPTIONS")
+ set(_QT5_DOING_OPTIONS TRUE)
+ else()
+ if(_QT5_DOING_OPTIONS)
+ list(APPEND ${_qt5_options} "${_currentArg}")
+ else()
+ list(APPEND ${_qt5_files} "${_currentArg}")
+ endif()
+ endif()
+ endforeach()
+endmacro()
-MACRO(QT5_CREATE_TRANSLATION _qm_files)
- QT5_EXTRACT_OPTIONS(_lupdate_files _lupdate_options ${ARGN})
- SET(_my_sources)
- SET(_my_dirs)
- SET(_my_tsfiles)
- SET(_ts_pro)
- FOREACH (_file ${_lupdate_files})
- GET_FILENAME_COMPONENT(_ext ${_file} EXT)
- GET_FILENAME_COMPONENT(_abs_FILE ${_file} ABSOLUTE)
- IF(_ext MATCHES "ts")
- LIST(APPEND _my_tsfiles ${_abs_FILE})
- ELSE(_ext MATCHES "ts")
- IF(NOT _ext)
- LIST(APPEND _my_dirs ${_abs_FILE})
- ELSE(NOT _ext)
- LIST(APPEND _my_sources ${_abs_FILE})
- ENDIF(NOT _ext)
- ENDIF(_ext MATCHES "ts")
- ENDFOREACH(_file)
- FOREACH(_ts_file ${_my_tsfiles})
- IF(_my_sources)
- # make a .pro file to call lupdate on, so we don't make our commands too
- # long for some systems
- GET_FILENAME_COMPONENT(_ts_name ${_ts_file} NAME_WE)
- SET(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro)
- SET(_pro_srcs)
- FOREACH(_pro_src ${_my_sources})
- SET(_pro_srcs "${_pro_srcs} \"${_pro_src}\"")
- ENDFOREACH(_pro_src ${_my_sources})
- FILE(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}")
- ENDIF(_my_sources)
- ADD_CUSTOM_COMMAND(OUTPUT ${_ts_file}
- COMMAND ${QT_LUPDATE_EXECUTABLE}
- ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file}
- DEPENDS ${_my_sources} ${_ts_pro} VERBATIM)
- ENDFOREACH(_ts_file)
- QT5_ADD_TRANSLATION(${_qm_files} ${_my_tsfiles})
-ENDMACRO(QT5_CREATE_TRANSLATION)
+macro(QT5_CREATE_TRANSLATION _qm_files)
+ qt5_extract_options(_lupdate_files _lupdate_options ${ARGN})
+ set(_my_sources)
+ set(_my_dirs)
+ set(_my_tsfiles)
+ set(_ts_pro)
+ foreach(_file ${_lupdate_files})
+ get_filename_component(_ext ${_file} EXT)
+ get_filename_component(_abs_FILE ${_file} ABSOLUTE)
+ if(_ext MATCHES "ts")
+ list(APPEND _my_tsfiles ${_abs_FILE})
+ else()
+ if(NOT _ext)
+ list(APPEND _my_dirs ${_abs_FILE})
+ else()
+ list(APPEND _my_sources ${_abs_FILE})
+ endif()
+ endif()
+ endforeach()
+ foreach(_ts_file ${_my_tsfiles})
+ if(_my_sources)
+ # make a .pro file to call lupdate on, so we don't make our commands too
+ # long for some systems
+ get_filename_component(_ts_name ${_ts_file} NAME_WE)
+ set(_ts_pro ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lupdate.pro)
+ set(_pro_srcs)
+ foreach(_pro_src ${_my_sources})
+ set(_pro_srcs "${_pro_srcs} \"${_pro_src}\"")
+ endforeach()
+ file(WRITE ${_ts_pro} "SOURCES = ${_pro_srcs}")
+ endif()
+ add_custom_command(OUTPUT ${_ts_file}
+ COMMAND ${QT_LUPDATE_EXECUTABLE}
+ ARGS ${_lupdate_options} ${_ts_pro} ${_my_dirs} -ts ${_ts_file}
+ DEPENDS ${_my_sources} ${_ts_pro} VERBATIM)
+ endforeach()
+ qt5_add_translation(${_qm_files} ${_my_tsfiles})
+endmacro()
-MACRO(QT5_ADD_TRANSLATION _qm_files)
- FOREACH (_current_FILE ${ARGN})
- GET_FILENAME_COMPONENT(_abs_FILE ${_current_FILE} ABSOLUTE)
- GET_FILENAME_COMPONENT(qm ${_abs_FILE} NAME_WE)
- GET_SOURCE_FILE_PROPERTY(output_location ${_abs_FILE} OUTPUT_LOCATION)
- IF(output_location)
- FILE(MAKE_DIRECTORY "${output_location}")
- SET(qm "${output_location}/${qm}.qm")
- ELSE(output_location)
- SET(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
- ENDIF(output_location)
- ADD_CUSTOM_COMMAND(OUTPUT ${qm}
- COMMAND ${QT_LRELEASE_EXECUTABLE}
- ARGS ${_abs_FILE} -qm ${qm}
- DEPENDS ${_abs_FILE} VERBATIM
- )
- SET(${_qm_files} ${${_qm_files}} ${qm})
- ENDFOREACH (_current_FILE)
-ENDMACRO(QT5_ADD_TRANSLATION)
+macro(QT5_ADD_TRANSLATION _qm_files)
+ foreach(_current_FILE ${ARGN})
+ get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
+ get_filename_component(qm ${_abs_FILE} NAME_WE)
+ get_source_file_property(output_location ${_abs_FILE} OUTPUT_LOCATION)
+ if(output_location)
+ file(MAKE_DIRECTORY "${output_location}")
+ set(qm "${output_location}/${qm}.qm")
+ else()
+ set(qm "${CMAKE_CURRENT_BINARY_DIR}/${qm}.qm")
+ endif()
+
+ add_custom_command(OUTPUT ${qm}
+ COMMAND ${QT_LRELEASE_EXECUTABLE}
+ ARGS ${_abs_FILE} -qm ${qm}
+ DEPENDS ${_abs_FILE} VERBATIM
+ )
+ set(${_qm_files} ${${_qm_files}} ${qm})
+ endforeach()
+endmacro()
include(MacroAddFileDependencies)
-MACRO (QT5_EXTRACT_OPTIONS _qt5_files _qt5_options)
- SET(${_qt5_files})
- SET(${_qt5_options})
- SET(_QT5_DOING_OPTIONS FALSE)
- FOREACH(_currentArg ${ARGN})
- IF ("${_currentArg}" STREQUAL "OPTIONS")
- SET(_QT5_DOING_OPTIONS TRUE)
- ELSE ("${_currentArg}" STREQUAL "OPTIONS")
- IF(_QT5_DOING_OPTIONS)
- LIST(APPEND ${_qt5_options} "${_currentArg}")
- ELSE(_QT5_DOING_OPTIONS)
- LIST(APPEND ${_qt5_files} "${_currentArg}")
- ENDIF(_QT5_DOING_OPTIONS)
- ENDIF ("${_currentArg}" STREQUAL "OPTIONS")
- ENDFOREACH(_currentArg)
-ENDMACRO (QT5_EXTRACT_OPTIONS)
-
-
-MACRO(QT5_ADD_DBUS_INTERFACE _sources _interface _basename)
- GET_FILENAME_COMPONENT(_infile ${_interface} ABSOLUTE)
- SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
- SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
- SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
-
- GET_SOURCE_FILE_PROPERTY(_nonamespace ${_interface} NO_NAMESPACE)
- IF(_nonamespace)
- SET(_params -N -m)
- ELSE(_nonamespace)
- SET(_params -m)
- ENDIF(_nonamespace)
-
- GET_SOURCE_FILE_PROPERTY(_classname ${_interface} CLASSNAME)
- IF(_classname)
- SET(_params ${_params} -c ${_classname})
- ENDIF(_classname)
-
- GET_SOURCE_FILE_PROPERTY(_include ${_interface} INCLUDE)
- IF(_include)
- SET(_params ${_params} -i ${_include})
- ENDIF(_include)
-
- ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
- COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile}
- DEPENDS ${_infile} VERBATIM)
-
- SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
-
- QT5_GENERATE_MOC(${_header} ${_moc})
-
- SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
- MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
-
-ENDMACRO(QT5_ADD_DBUS_INTERFACE)
-
-
-MACRO(QT5_ADD_DBUS_INTERFACES _sources)
- FOREACH (_current_FILE ${ARGN})
- GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE)
- # get the part before the ".xml" suffix
- STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
- STRING(TOLOWER ${_basename} _basename)
- QT5_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
- ENDFOREACH (_current_FILE)
-ENDMACRO(QT5_ADD_DBUS_INTERFACES)
-
-
-MACRO(QT5_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options )
- QT5_EXTRACT_OPTIONS(_customName _qt4_dbus_options ${ARGN})
-
- GET_FILENAME_COMPONENT(_in_file ${_header} ABSOLUTE)
- GET_FILENAME_COMPONENT(_basename ${_header} NAME_WE)
-
- IF (_customName)
- if (IS_ABSOLUTE ${_customName})
- get_filename_component(_containingDir ${_customName} PATH)
- if (NOT EXISTS ${_containingDir})
- file(MAKE_DIRECTORY "${_containingDir}")
- endif()
- SET(_target ${_customName})
+macro(QT5_EXTRACT_OPTIONS _qt5_files _qt5_options)
+ set(${_qt5_files})
+ set(${_qt5_options})
+ set(_QT5_DOING_OPTIONS FALSE)
+ foreach(_currentArg ${ARGN})
+ if("${_currentArg}" STREQUAL "OPTIONS")
+ set(_QT5_DOING_OPTIONS TRUE)
+ else()
+ if(_QT5_DOING_OPTIONS)
+ list(APPEND ${_qt5_options} "${_currentArg}")
+ else()
+ list(APPEND ${_qt5_files} "${_currentArg}")
+ endif()
+ endif()
+ endforeach()
+endmacro()
+
+
+macro(QT5_ADD_DBUS_INTERFACE _sources _interface _basename)
+ get_filename_component(_infile ${_interface} ABSOLUTE)
+ set(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
+ set(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
+ set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
+
+ get_source_file_property(_nonamespace ${_interface} NO_NAMESPACE)
+ if(_nonamespace)
+ set(_params -N -m)
else()
- SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
+ set(_params -m)
endif()
- ELSE (_customName)
- SET(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
- ENDIF (_customName)
-
- ADD_CUSTOM_COMMAND(OUTPUT ${_target}
- COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target}
- DEPENDS ${_in_file} VERBATIM
- )
-ENDMACRO(QT5_GENERATE_DBUS_INTERFACE)
-
-
-MACRO(QT5_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName)
- GET_FILENAME_COMPONENT(_infile ${_xml_file} ABSOLUTE)
-
- SET(_optionalBasename "${ARGV4}")
- IF (_optionalBasename)
- SET(_basename ${_optionalBasename} )
- ELSE (_optionalBasename)
- STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
- STRING(TOLOWER ${_basename} _basename)
- ENDIF (_optionalBasename)
-
- SET(_optionalClassName "${ARGV5}")
- SET(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
- SET(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
- SET(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
-
- IF(_optionalClassName)
- ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
- COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
- DEPENDS ${_infile} VERBATIM
+
+ get_source_file_property(_classname ${_interface} CLASSNAME)
+ if(_classname)
+ set(_params ${_params} -c ${_classname})
+ endif()
+
+ get_source_file_property(_include ${_interface} INCLUDE)
+ if(_include)
+ set(_params ${_params} -i ${_include})
+ endif()
+
+ add_custom_command(OUTPUT ${_impl} ${_header}
+ COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} ${_params} -p ${_basename} ${_infile}
+ DEPENDS ${_infile} VERBATIM)
+
+ set_source_files_properties(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
+
+ qt5_generate_moc(${_header} ${_moc})
+
+ set(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
+ macro_add_file_dependencies(${_impl} ${_moc}))
+endmacro()
+
+
+macro(QT5_ADD_DBUS_INTERFACES _sources)
+ foreach(_current_FILE ${ARGN})
+ get_filename_component(_infile ${_current_FILE} ABSOLUTE)
+ # get the part before the ".xml" suffix
+ string(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
+ string(TOLOWER ${_basename} _basename)
+ qt5_add_dbus_interface(${_sources} ${_infile} ${_basename}interface)
+ endforeach()
+endmacro()
+
+
+macro(QT5_GENERATE_DBUS_INTERFACE _header) # _customName OPTIONS -some -options )
+ qt5_extract_options(_customName _qt4_dbus_options ${ARGN})
+
+ get_filename_component(_in_file ${_header} ABSOLUTE)
+ get_filename_component(_basename ${_header} NAME_WE)
+
+ if(_customName)
+ if(IS_ABSOLUTE ${_customName})
+ get_filename_component(_containingDir ${_customName} PATH)
+ if(NOT EXISTS ${_containingDir})
+ file(MAKE_DIRECTORY "${_containingDir}")
+ endif()
+ set(_target ${_customName})
+ else()
+ set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_customName})
+ endif()
+ else()
+ set(_target ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.xml)
+ endif()
+
+ add_custom_command(OUTPUT ${_target}
+ COMMAND ${QT_DBUSCPP2XML_EXECUTABLE} ${_qt4_dbus_options} ${_in_file} -o ${_target}
+ DEPENDS ${_in_file} VERBATIM
)
- ELSE(_optionalClassName)
- ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
- COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
- DEPENDS ${_infile} VERBATIM
- )
- ENDIF(_optionalClassName)
-
- QT5_GENERATE_MOC(${_header} ${_moc})
- SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
- MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
-
- SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
-ENDMACRO(QT5_ADD_DBUS_ADAPTOR)
+endmacro()
+
+
+macro(QT5_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optionalBasename _optionalClassName)
+ get_filename_component(_infile ${_xml_file} ABSOLUTE)
+
+ set(_optionalBasename "${ARGV4}")
+ if(_optionalBasename)
+ set(_basename ${_optionalBasename} )
+ else()
+ string(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2adaptor" _basename ${_infile})
+ string(TOLOWER ${_basename} _basename)
+ endif()
+
+ set(_optionalClassName "${ARGV5}")
+ set(_header ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
+ set(_impl ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
+ set(_moc ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.moc)
+
+ if(_optionalClassName)
+ add_custom_command(OUTPUT ${_impl} ${_header}
+ COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
+ DEPENDS ${_infile} VERBATIM
+ )
+ else()
+ add_custom_command(OUTPUT ${_impl} ${_header}
+ COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
+ DEPENDS ${_infile} VERBATIM
+ )
+ endif()
+
+ qt5_generate_moc(${_header} ${_moc})
+ set_source_files_properties(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
+ macro_add_file_dependencies(${_impl} ${_moc})
+
+ set(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
+endmacro()