With qmake, how to compile moc files with different compiler options?
Unsolved
Qt Creator and other tools
-
In our Qt project, we use gcc option -Wuseless-cast, and we treat warnings as errors (-Werror).
When gcc compiles C++ files generated by moc (say, moc_foo.cpp), -Wuseless-cast generates warnings (and thus errors):
moc_foo.cpp: In static member function ‘static void Foo::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)’: moc_foo.cpp:78:84: error: useless cast to type ‘_t {aka void (Foo::*)() const}’ [-Werror=useless-cast] if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&Foo::bar)) {
How could we instruct qmake to pass option -Wno-useless-cast to gcc when compiling modules generated by moc?
We use Qt 5.12 and gcc 7.5.
-
You can't. See e.g. https://bugreports.qt.io/browse/QTBUG-71938 and feel free to provide a patch for it.