views:

911

answers:

2

Hello,

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?

A: 

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.

Jonathan Leffler
+2  A: 

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.

jon hanson
Correct, the warnings come from the third-party headers. I will look into pragmas, but is there a way I can inject them only into the third-party headers, or will I have to edit their headers?
Kevin Bowling
You could introduce header wrappers for the third party headers. One brute-force approach would be to put any include for a third party header into a single header, then your app just includes that header where necessary. E.g. if your App uses library Zed then create a zed.h header which includes all Zed headers. Then you can add the pragmas to zed.h.Or just go through your code and surround each #include <zed/some_header.h> with pragmas.
jon hanson