[CMake] how to use qt4_wrap_cpp

Tyler tyler at cryptio.net
Thu Jun 3 16:13:38 EDT 2010


Wow, epic bump. Ccing the list so others can jump in.

On Thu, Jun 03, 2010 at 10:09:04PM +0200, Daniel Dekkers wrote:
> Working on Qt and cmake. You wrote.
>
> 
> I just spent some time struggling with this macro so I wanted to post an
> example. Maybe this can be used to expand on the documentation.
> 
> First you need to collect all the headers on which you want to run moc:
>
> set (FOO_MOC_HEADERS foo_header.h)


> . now I was wondering if you have to enumerate all the headers by hand.
> Can't I just take all header files and "moc" them. I was hoping that moc
> would ignore header files without the Q_OBJECT makro (which doesn't seem to
> be the case when using cmake).

I recommend enumerating all the headers. If you're worried about
duplication, you can have a variable MOC_HEADERS and another variable
HEADERS, then before your add_library() or add_executable(), combine
them into ALL_HEADERS.

You can also take a look at the qt4_automoc() macro from FindQt4.cmake.

hth,
tyler


More information about the CMake mailing list