Browse Source

Merge topic 'qt4-macros'

0331a5a Qt4Macros: add some quotes to prevent damage from spaces in the paths
f46903b Qt4Macros: improve basename extraction in QT4_ADD_DBUS_INTERFACES
aa841ae FindQt4: extend documentation
David Cole 13 years ago
parent
commit
fd8fc2791b
2 changed files with 38 additions and 24 deletions
  1. 19 6
      Modules/FindQt4.cmake
  2. 19 18
      Modules/Qt4Macros.cmake

+ 19 - 6
Modules/FindQt4.cmake

@@ -102,15 +102,28 @@
 #        accompanying header file foo.h.
 #        If a source file has the SKIP_AUTOMOC property set it will be ignored by this macro.
 #
+#        You should have a look on the AUTOMOC property for targets to achieve the same results.
+#
 #  macro QT4_ADD_DBUS_INTERFACE(outfiles interface basename)
-#        create a the interface header and implementation files with the 
+#        Create a the interface header and implementation files with the
 #        given basename from the given interface xml file and add it to 
-#        the list of sources
+#        the list of sources.
+#
+#        You can pass additional parameters to the qdbusxml2cpp call by setting
+#        properties on the input file:
+#
+#        INCLUDE the given file will be included in the generate interface header
+#
+#        CLASSNAME the generated class is named accordingly
+#
+#        NO_NAMESPACE the generated class is not wrapped in a namespace
 #
 #  macro QT4_ADD_DBUS_INTERFACES(outfiles inputfile ... )
-#        create the interface header and implementation files 
-#        for all listed interface xml files
-#        the name will be automatically determined from the name of the xml file
+#        Create the interface header and implementation files
+#        for all listed interface xml files.
+#        The basename will be automatically determined from the name of the xml file.
+#
+#        The source file properties described for QT4_ADD_DBUS_INTERFACE also apply here.
 #
 #  macro QT4_ADD_DBUS_ADAPTOR(outfiles xmlfile parentheader parentclassname [basename] [classname])
 #        create a dbus adaptor (header and implementation file) from the xml file
@@ -217,7 +230,7 @@
 #  QT_QAXCONTAINER_INCLUDE_DIR Path to "include/ActiveQt" (Windows only)
 #  QT_QAXSERVER_INCLUDE_DIR    Path to "include/ActiveQt" (Windows only)
 #  QT_QTCORE_INCLUDE_DIR       Path to "include/QtCore"         
-#  QT_QTDBUS_INCLUDE_DIR       Path to "include/QtDBus" 
+#  QT_QTDBUS_INCLUDE_DIR       Path to "include/QtDBus"
 #  QT_QTDESIGNER_INCLUDE_DIR   Path to "include/QtDesigner" 
 #  QT_QTDESIGNERCOMPONENTS_INCLUDE_DIR   Path to "include/QtDesigner"
 #  QT_QTGUI_INCLUDE_DIR        Path to "include/QtGui" 

+ 19 - 18
Modules/Qt4Macros.cmake

@@ -220,9 +220,9 @@ ENDMACRO (QT4_ADD_RESOURCES)
 
 MACRO(QT4_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)
+  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)
@@ -241,16 +241,16 @@ MACRO(QT4_ADD_DBUS_INTERFACE _sources _interface _basename)
     SET(_params ${_params} -i ${_include})
   ENDIF(_include)
 
-  ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
+  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)
+  SET_SOURCE_FILES_PROPERTIES("${_impl}" PROPERTIES SKIP_AUTOMOC TRUE)
 
-  QT4_GENERATE_MOC(${_header} ${_moc})
+  QT4_GENERATE_MOC("${_header}" "${_moc}")
 
-  SET(${_sources} ${${_sources}} ${_impl} ${_header} ${_moc})
-  MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
+  LIST(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}")
+  MACRO_ADD_FILE_DEPENDENCIES("${_impl}" "${_moc}")
 
 ENDMACRO(QT4_ADD_DBUS_INTERFACE)
 
@@ -258,9 +258,10 @@ ENDMACRO(QT4_ADD_DBUS_INTERFACE)
 MACRO(QT4_ADD_DBUS_INTERFACES _sources)
   FOREACH (_current_FILE ${ARGN})
     GET_FILENAME_COMPONENT(_infile ${_current_FILE} ABSOLUTE)
+    GET_FILENAME_COMPONENT(_basename ${_current_FILE} NAME)
     # get the part before the ".xml" suffix
-    STRING(REGEX REPLACE "(.*[/\\.])?([^\\.]+)\\.xml" "\\2" _basename ${_current_FILE})
     STRING(TOLOWER ${_basename} _basename)
+    STRING(REGEX REPLACE "(.*\\.)?([^\\.]+)\\.xml" "\\2" _basename ${_basename})
     QT4_ADD_DBUS_INTERFACE(${_sources} ${_infile} ${_basename}interface)
   ENDFOREACH (_current_FILE)
 ENDMACRO(QT4_ADD_DBUS_INTERFACES)
@@ -305,27 +306,27 @@ MACRO(QT4_ADD_DBUS_ADAPTOR _sources _xml_file _include _parentClass) # _optional
   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)
+  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}
+    ADD_CUSTOM_COMMAND(OUTPUT "${_impl}" "${_header}"
        COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -c ${_optionalClassName} -i ${_include} -l ${_parentClass} ${_infile}
        DEPENDS ${_infile} VERBATIM
     )
   ELSE(_optionalClassName)
-    ADD_CUSTOM_COMMAND(OUTPUT ${_impl} ${_header}
+    ADD_CUSTOM_COMMAND(OUTPUT "${_impl}" "${_header}"
        COMMAND ${QT_DBUSXML2CPP_EXECUTABLE} -m -a ${_basename} -i ${_include} -l ${_parentClass} ${_infile}
        DEPENDS ${_infile} VERBATIM
      )
   ENDIF(_optionalClassName)
 
-  QT4_GENERATE_MOC(${_header} ${_moc})
-  SET_SOURCE_FILES_PROPERTIES(${_impl} PROPERTIES SKIP_AUTOMOC TRUE)
-  MACRO_ADD_FILE_DEPENDENCIES(${_impl} ${_moc})
+  QT4_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})
+  LIST(APPEND ${_sources} "${_impl}" "${_header}" "${_moc}")
 ENDMACRO(QT4_ADD_DBUS_ADAPTOR)