[CMake] Problems with Qt MOC and conditional compilation.

Tim Sutton tim at linfiniti.com
Tue Mar 13 11:50:51 EST 2007


Hi all

Can someone help me with getting conditionally #defined code blog to
compile using cmake?
My CmakeLists.txt file has: ADD_DEFINITIONS(-DWITH_QGIS) and I have
some code blocks in .h and .cpp that conditionally compile based on
this e.g.

#ifdef WITH_QGIS
    foo...
#endif

The problem I have is that only the ifdefs in the .cpp are properly
being entered into & compiled, while in the .h the code is skipped. My
theory is this is because the -DWITH_QGIS is not being passed along to
MOC when it is run on the header file.

 87 #ifdef WITH_QGIS
 88       void zoomInMode();
 89       void zoomOutMode();
           etc...
 99 #endif

If I comment out the ifdef, MOC runs and my Qt slots work properly.
Has anyone encountered a similar issue? I am using cmake version
2.4-patch 5 on ubuntu feisty. When compiled with qmake the same code
works fine so I am thinking this is coming back to the way that cmake
is calling moc?

Many thanks!

-- 
-- 
Tim Sutton

Visit http://qgis.org for a great Open Source GIS
Home Page: http://linfiniti.com
Skype: timlinux
MSN: tim_bdworld at msn.com
Yahoo: tim_bdworld at yahoo.com
Jabber: timlinux
Irc: timlinux on #qgis at freenode.net


More information about the CMake mailing list