[CMake] Problems with Qt MOC and conditional compilation.

Filipe Sousa natros at gmail.com
Tue Mar 13 15:18:45 EST 2007


Tim Sutton wrote:
> Hi Filipe
> 
...
> 
> When I try to compile (using make VERBOSE=1) now I get the following error:
> 
> [ 51%] Generating moc_omgmainwindow.cxx
> cd /home/timlinux/dev/cpp/openModellerDesktop/build/src/gui &&
> /usr/bin/moc-qt4 -I /usr/include/qt4 -I /usr/include/qt4/Qt3Support -I
> /usr/include/qt4/QtSvg -I /usr/include/qt4/QtGui -I
> /usr/include/qt4/QtXml -I /usr/include/qt4/QtNetwork -I
> /usr/include/qt4/QtCore -DWITH_QGIS -DOMG_NO_EXPERIMENTAL -DQT_SHARED
> -DQT_3SUPPORT_LIB -DQT3_SUPPORT -DQT_SVG_LIB -DQT_GUI_LIB -DQT_XML_LIB
> -DQT_NETWORK_LIB -DQT_CORE_LIB -Wall -Werror -DCORE_EXPORT=
> -DPLUGIN_EXPORT= -DGUI_EXPORT= -o
> /home/timlinux/dev/cpp/openModellerDesktop/build/src/gui/moc_omgmainwindow.cxx
> /home/timlinux/dev/cpp/openModellerDesktop/src/gui/omgmainwindow.h
> moc: Invalid argument
> Usage: moc [options] <header-file>
>   -o<file>           write output to file rather than stdout
>   -I<dir>            add dir to the include path for header files
>   -E                 preprocess only; do not generate meta object code
>   -D<macro>[=<def>]  define macro, with optional definition
>   -U<macro>          undefine macro
>   -i                 do not generate an #include statement
>   -p<path>           path prefix for included file
>   -f[<file>]         force #include, optional file name
>   -nw                do not display warnings
>   -v                 display version of moc
> make[2]: *** [src/gui/moc_omgmainwindow.cxx] Error 1
> make[2]: Leaving directory `/home/timlinux/dev/cpp/openModellerDesktop/build'
> make[1]: *** [src/gui/CMakeFiles/openModellerDesktop.dir/all] Error 2
> make[1]: Leaving directory `/home/timlinux/dev/cpp/openModellerDesktop/build'
> make: *** [all] Error 2
> 

Hi Tim,

The problem here is that GET_DIRECTORY_PROPERTY(_flags DEFINITIONS) is 
getting other compiler flags that shouldn't be there.

Are you using ADD_DEFINITONS() to add other compiler flags (-Wall 
-Werror)? ADD_DEFINITIONS() should be used only to add definitions 
(-D...) to preprocessor. For compiler one should use CMAKE_CXX_FLAGS or 
CMAKE_C_FLAGS.


--
Filipe Sousa


More information about the CMake mailing list