[CMake] CMake with Qt (plus pkg-config)
Bill Hoffman
bill.hoffman at kitware.com
Thu Oct 22 08:37:11 EDT 2009
Murray Cumming wrote:
> I'm trying to use CMake for the first time, as an experiment, with
> little a Qt-based project. It also uses an additional library, via
> pkg-config.
>
> So far Qt's include files don't seem to be found, and I wonder how I can
> cause moc to be used to generate some of the .cc files.
>
> Here's what I have so far:
> http://github.com/murraycu/qlom/blob/qlom_cmake/CMakeLists.txt
> based on the many and varied google results.
>
> Can anyone give me some clues?
>
>
There is this link here:
http://qtnode.net/wiki/Qt_with_cmake
Although that uses automoc which I don't like that much... :)
The CMake cmake-gui program is a good example and can be seen here:
http://public.kitware.com/cgi-bin/viewcvs.cgi/Source/QtDialog/CMakeLists.txt?revision=1.24&root=CMake&view=markup
So, what you are missing is the moc step.
QT4_WRAP_CPP(MOC_SRCS header1.h header2.h)
add_executable(qlom ${QLOM_SOURCES} ${MOC_SRCS})
The QT4_WRAP_CPP macro will call moc on all the files listed during
build time and create the moc files. The names of the files that will
be created are placed in the variable MOC_SRCS, which you then have to
add to an executable or library target.
-Bill
More information about the CMake
mailing list