Hi,
while wrestling with QtDBus today I found out the hard way (i.e. reading the
source) that QT4_ADD_DBUS_INTERFACE is much more powerful than its
documentation tells. To fix that the first patch now tells about the
properties you may set on the input file. While at it I also added a reference
from QT4_AUTOMOC macro to the new AUTOMOC property.
The other 2 patches improve some things I found while reading the source code.
Patch #2 uses get_filename_component to strip the path from the given input
file (why implement something again that we already have?). It also applies
string(TOLOWER) earlier so that an XML file with an upper or mixed case
extension (FAT anyone?) will also be properly handled.
Patch #3 finally wraps a lot of set(...) in quotes when the argument may
contain spaces, e.g. CMAKE_CURRENT_BINARY_DIR. It also uses LIST(APPEND) to
add to the list of source files instead of just using set(). Together with
additional quotes this should make things much less likely to screw up things.
If noone objects I'll merge this to next tonight. Running the testsuite
locally did not show any errors.
Eike
>From af7f8bd6bb23ef2e68fe53b16baae3f84f25b48d Mon Sep 17 00:00:00 2001
From: Rolf Eike Beer <[email protected]>
Date: Wed, 20 Jun 2012 13:11:40 +0200
Subject: [PATCH 1/3] FindQt4: extend documentation
-refer to AUTOMOC from QT4_AUTOMOC
-mention how source file properties influence QT4_ADD_DBUS_INTERFACE
---
Modules/FindQt4.cmake | 25 +++++++++++++++++++------
1 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake
index 391797e..2f1708d 100644
--- a/Modules/FindQt4.cmake
+++ b/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"
--
1.7.7.3
>From 8929188877596d745e9cec4eec7ae337a5d8e3ca Mon Sep 17 00:00:00 2001
From: Rolf Eike Beer <[email protected]>
Date: Wed, 20 Jun 2012 13:23:40 +0200
Subject: [PATCH 2/3] Qt4Macros: improve basename extraction in
QT4_ADD_DBUS_INTERFACES
-convert the filename to lowercase before the extraction, this allows this to
work even if the filename as uppercase ".XML" extension
-use get_filename_component(... NAME) to strip the path
---
Modules/Qt4Macros.cmake | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake
index f867bc5..7170711 100644
--- a/Modules/Qt4Macros.cmake
+++ b/Modules/Qt4Macros.cmake
@@ -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)
--
1.7.7.3
>From 8a8baa8a25bf0af0855351a57689af1fa22da948 Mon Sep 17 00:00:00 2001
From: Rolf Eike Beer <[email protected]>
Date: Wed, 20 Jun 2012 13:29:45 +0200
Subject: [PATCH 3/3] Qt4Macros: add some quotes to prevent damage from spaces
in the paths
---
Modules/Qt4Macros.cmake | 34 +++++++++++++++++-----------------
1 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake
index 7170711..68f3c80 100644
--- a/Modules/Qt4Macros.cmake
+++ b/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)
@@ -306,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)
--
1.7.7.3
--
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers