I use qmake as a makefile builder and want to stick to it. Further I would like to use "gcc -Wall -Werror -Wundef -Wextra" to get robust code. I'm thinking about "-pedantic" but that's further up the road. My main problem at the moment are the tons of warnings generated by libraries like boost, parts of qt and the like.
At the moment I use pragmas whenever I include warning-generating headers
#pragma GCC diagnostic ignored "-Wall"
#include <QtGui>
...
#include <QWidget>
#pragma GCC diagnostic error "-Wall"
This is far from cute, rather tedious and cumbersome especially as other programmers have to do so too. Is there an option using qmake that allows to include qt-libraries as system headers, thus supressing their warnings. For plain makefiles and cmake I knwow -isystem but I cannot find a qmake pendant for this.
I just added this to my macx-clang/qmake.conf:
QMAKE_CXXFLAGS += $$join(QMAKE_INCDIR_QT, " -isystem", "-isystem")
works nicely now.
Came up with a workaround: manually changing Makefile.
Add this line to .pro file
And then create an executable file suppress_system_warnings.sh
Since many settings are hardcoded into spec files, I think you need to create your own. Start with reading mkspecs/linux-g++/qmake.conf or mkspecs/win32-g++/qmake.conf
You will see that by default CONFIG uses warn_on setting. and in mkspecs/common/g++ you have
so you can change the spec file and make new settings default for every project, or you can set this variables in your project file.
qt include path is hardcoded in mkspecs/features/qt.prf as
You don't want QMAKE_INCDIR_QT to be a part of INCLUDEPATH since its components are joined with -I. You want to expand it as $$join(QMAKE_INCDIR_QT, " -isystem", "-isystem") somewhere else...
Note that the correct answer to this one is to use the SYSTEM keyword in the include_target() macro:
This works for many libraries, not just Qt which I could use without too much problems. But the Magic++.h is really a horrible piece of work in comparison and I had to have this capability.
You can find more information on this question:
Use -isystem instead of -I with CMake
Easiest way I found is including directly via QMAKE_CXXFLAGS e.g. for Boost this looks like the following in the project file