[CMake] -DNDEBUG passed to Qt moc compiler

Nicolas Desprès nicolas.despres at gmail.com
Wed Sep 3 07:41:53 EDT 2008


Hi,

I'm using cmake 2.6.0 and Qt-4.4.1 commercial on windows. While trying
to compile my Qt application in release mode using
-DCMAKE_BUILD_TYPE=Release, I met a problem with conditional Qt slots.
In one of my header, I have something like that:

#ifndef NDEBUG
  void mySlot()
#endif

In debug mode, there is no problem. But in release mode my C++
compiler complains that it cannot find the identifier "mySlot"  when
it compiles the source file generated by Qt's moc compiler.

Adding:
 -D
 NDEBUG

in the parameter file given to moc in the build tree fixed the issue.

I suggest that FindQt4 module could handle such issue automatically.

Cheers,

-- 
Nicolas Desprès


More information about the CMake mailing list