[CMake] Qt4 moc and uic macros

Alexander Neundorf a.neundorf-work at gmx.net
Thu Jun 8 09:19:26 EDT 2006


Hi,

> Von: Patrick Noffke <Patrick.Noffke at adpro.com.au>
> 
> All,
> 
> I've written the following macros (the first one based on the existing 
> QT4_AUTOMOC macro) to improve the handling of moc and uic generated files 
> with Qt4.  The "qmake way" is to generate moc_xxx.cpp files for headers 
> that contain Q_OBJECT, and automatically include them as part of the
> build. 

Do you have problems using QT4_WRAP_CPP() ? If so, I'd suggest to fix them instead of adding yet another moc macro.

>  The QT4_AUTOMOC2 macro below does this.  An example usage of the macro 
> would be as follows:
> 
> SET(foo_SRCS
>   Class1.cpp
>   Class2.cpp
>   some_dir/Class3.cpp
> )
> 
> SET(foo_MOC_HDRS
>   Class1.h
>   Class2.h
>   some_dir/Class3.h
> )
> 
> # Returns the moc_xxx.cpp files in the foo_MOC_SRCS variable
> QT4_AUTOMOC2(foo_MOC_SRCS ${axiom_setup_MOC_HDRS})
> 
> ADD_EXECUTABLE(foo ${foo_SRCS} ${foo_MOC_SRCS})
> 
> The QT4_AUTOUIC macro allows you to automatically run uic on .ui files and
> creates a dependency of the ui_xxxx.h by xxxx.cpp (since this is the
> file that #include's ui_xxxx.h).  An example usage would be as follows:

In which way does this differ from the QT4_WRAP_UI() macro coming with cmake 2.4.2 ? It should do the same. Doesn't it work for you ?

Do you have problems with the include dirs ?
Then try adding CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR to the include dirs. (you can do this also using SET(CMAKE_INCLUDE_CURRENT_DIR ON) )

Bye
Alex

-- 


Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer


More information about the CMake mailing list