Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, December 2007
CMake + QtDbus + qdbuscpp2xml


Message 1 in thread

I am trying to create a small prototype which uses D-Bus for communication between processes therefore I want to use a .xml interface description, like it is used in the Qt examples. But as you see on the topic I want to build it with CMake (because later the whole project will be build with CMake).
I found a FindQt4.cmake module at the KDE SVN which provides a function called QT4_ADD_DBUS_INTERFACE, but because it is used by KDE 4 there is not much documentation how to use it right now. So I hope someone on this list might be able to help me.

My CMakeLists.txt so far:
PROJECT (DBus prototype")

SET (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "./modules/" )
SET (QT_USE_QTDBUS true)

IF (CMAKE_COMPILER_IS_GNUCXX)
	ADD_DEFINITIONS(-g)
ENDIF (CMAKE_COMPILER_IS_GNUCXX)
ADD_DEFINITIONS (-Wall)

SET (BINARY dBusProto)
FIND_PACKAGE(Qt4 REQUIRED)
SET (SRC
	main.cpp
)
QT4_ADD_DBUS_INTERFACE (${SRC} org.rdld.gain.xml interface)
ADD_EXECUTABLE (${BINARY} ${SRC})

IF(QT4_FOUND)
	INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR})
	INCLUDE_DIRECTORIES(${QT_QT_INCLUDE_DIR})
	INCLUDE_DIRECTORIES(${QT_QTCORE_INCLUDE_DIR})
	INCLUDE_DIRECTORIES(${QT_QTDBUS_INCLUDE_DIR})
	TARGET_LINK_LIBRARIES(${BINARY}
			${QT_QTDBUS_LIBRARY}
			)
ENDIF(QT4_FOUND)
--------------------------
main.cpp:
int main (int argc, char ** argv)
{
	return (0);
}
----------------------------
org.rdld.gain.xml:
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
	  "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd";>
<node>
	<interface name="org.rdld.gain">
		<signal name="message">
			<arg name="text" type="s" direction="out"/>
		</signal>
	</interface>
</node>

If this does not belong to this list, you might give me a hint, which other list I should try. Anyway I hope you can help me.

Simon

Message 2 in thread

Sometimes writing about it just helps. I just found out that the macro from 
kde is not consistent to the normal syntax therefore the macro:
QT4_ADD_DBUS_INTERFACE (${SRC} org.rdld.gain.xml interface)

has wrong arguments it should be:
QT4_ADD_DBUS_INTERFACE (SRC org.rdld.gain.xml interface)

so SRC is not the content of the variable, but the name. I do not know why but 
it works.

Regards
Simon

Am Dienstag, 11. Dezember 2007 10:20:07 schrieb Simon Schäfer:
> I am trying to create a small prototype which uses D-Bus for communication
> between processes therefore I want to use a .xml interface description,
> like it is used in the Qt examples. But as you see on the topic I want to
> build it with CMake (because later the whole project will be build with
> CMake). I found a FindQt4.cmake module at the KDE SVN which provides a
> function called QT4_ADD_DBUS_INTERFACE, but because it is used by KDE 4
> there is not much documentation how to use it right now. So I hope someone
> on this list might be able to help me.

--
 [ signature omitted ] 

Message 3 in thread

On 11.12.07 13:44:48, Simon Schäfer wrote:
> Sometimes writing about it just helps. I just found out that the macro from 
> kde is not consistent to the normal syntax therefore the macro:
> QT4_ADD_DBUS_INTERFACE (${SRC} org.rdld.gain.xml interface)
> 
> has wrong arguments it should be:
> QT4_ADD_DBUS_INTERFACE (SRC org.rdld.gain.xml interface)
> 
> so SRC is not the content of the variable, but the name. I do not know why but 
> it works.

Because that macro uses the xml file to generate a header and cpp file
and adds both of them to the list of sources to be compiled.

And the documentation for this macro and others can be found in KDE4's
special FindQt4.cmake. So just put that file into a folder in your
project and use

set(CMAKE_MODULE_PATH folder ${CMAKE_MODULE_PATH})

to make CMake use your/kde's FindQt4.cmake instead of the cmake-shipped
one.

Andreas

-- 
 [ signature omitted ] 

Message 4 in thread

> Because that macro uses the xml file to generate a header and cpp file
> and adds both of them to the list of sources to be compiled.
Ah, ok that explains it.

> And the documentation for this macro and others can be found in KDE4's
> special FindQt4.cmake. 
Well now after I found out how the right syntax is I saw that the QT4_WRAP_CPP 
and QT4_ADD_RESOURCES macros are working in the same way and I already used 
them before. I just have not seen it (perhaps thats the reason for those 
glasses on my nose).

> So just put that file into a folder in your 
> project and use
>
> set(CMAKE_MODULE_PATH folder ${CMAKE_MODULE_PATH})
Like you can read in my first email i made it like that (found that on one of 
the kde CMakeLists.txt as well), but i think that my folder should come after 
the ${CMAKE_MODULE_PATH} variable, otherwise my FindQt4.cmake would be 
overloaded by the one in the CMAKE_MODULE_PATH. or am I wrong?

Thank you
Simon


--
 [ signature omitted ] 

Message 5 in thread

On 11.12.07 15:11:32, Simon Schäfer wrote:
> > So just put that file into a folder in your 
> > project and use
> >
> > set(CMAKE_MODULE_PATH folder ${CMAKE_MODULE_PATH})
> Like you can read in my first email i made it like that (found that on one of 

Didn't read that one actually :)

> the kde CMakeLists.txt as well), but i think that my folder should come after 
> the ${CMAKE_MODULE_PATH} variable, otherwise my FindQt4.cmake would be 
> overloaded by the one in the CMAKE_MODULE_PATH. or am I wrong?

You're wrong, cmake doesn't put its "built-in" module path into that variable, so
it only matters if you have more set for CMAKE_MODULE_PATH before that
one.

Andreas

-- 
 [ signature omitted ]