[CMake] Problems with Qt MOC and conditional compilation.
Filipe Sousa
natros at gmail.com
Tue Mar 13 13:37:47 EST 2007
Tim Sutton wrote:
> 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!
I've been looking into to the code and the preprocessor definitions is
missing
Add this code after QT4_GET_MOC_INC_DIRS(moc_includes) to the macro
QT4_WRAP_CPP (FinfQt4.cmake) and see if it works:
GET_DIRECTORY_PROPERTY(_flags DEFINITIONS)
SEPARATE_ARGUMENTS(_flags)
LIST(APPEND moc_includes ${_flags})
I didn't test
--
Filipe Sousa
More information about the CMake
mailing list