Question

I am involved with a software project written in Qt and built with qmake and gcc on Linux. We have to link to a third-party library that is of fairly low quality and spews tons of warnings. I would like to use -W -Wall on our source code, but pass -w to the nasty third-party library to keep the console free of noise and clutter so we can focus on our code quality.

In qmake, is there a way to conditionally add CFLAGS/CXXFLAGS to certain files and libraries?

Was it helpful?

Solution

Jonathan, I think the problem is where your source files are including header files from 3rd party libraries, and you want to switch off the warnings for the latter.

Kevin, i think you can use pragmas to control warnings : gcc diagnostic pragmas

You could add these before and after any #includes for 3rd party libs.

OTHER TIPS

What if you include your library using -isystem.

In the project file e.g.:

QMAKE_CXXFLAGS += -isystem /usr/local/boost_1_44_0

Kevin,

qmake CONFIG+=debug QMAKE_CXXFLAGS_WARN_ON=-w QMAKE_CFLAGS_WARN_ON=-w

should do (use CONFIG+=release if you wish...)

Normally, you'd build the third-party library in a separate directory from your own code, so you would have a different makefile for it, so you could put a different set of flags for that compilation.

If you've mixed the third-party library code with your own code, you have set yourself up for a maintenance nightmare.

As Martin wrote adding the include directory via

QMAKE_CXXFLAGS += -isystem ...

suppresses warnings just in the respective headers. No need to disable warnings for any source files of your project (or even project-wide) or mess with #pragmas or wrappers files.

Note that if you're using QtCreator you'll still (i.e. additionally) want add the directory to INCLUDEPATH so the indexer picks up the headers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top