[Solved] qmake: Where do additional CXXFLAGS come from?
I am trying to inhibit a certain warning on GCC. For that I added
@QMAKE_CXXFLAGS += -Wno-switch@
At the time I append this inhibition, my QMAKE_CXXFLAGS look like this:
However, in the resulting Makefile, my flags look like this:
@-pipe -Wno-switch -g -fPIC -Wall -W -D_REENTRANT $(DEFINES) @
Where do the additional flags come from? I assume that the -Wall later on cancels my request to inhibit that single warning (at least, the warning is still displayed). What can I do?
Check out the mkspecs.
Right on target!
How do I make my project-specific CXXFLAGS appear after those specified by the mkspecs? Because I do actually want -Wall, except for this one warning.
Uh, now that is trickier. I don't know a good answer to this (but there might be one). The first idea that comes to my mind is to modify the mkspecs: but then you will have to remember to use that specific modified version of mkspecs, especially after changing (upgrade) Qt version. The second idea.. what about that "$(DEFINES)" at the end of compiler call? Maybe you can add your flag to that variable?
I found a solution:
Do this within the project:
@CONFIG -= warn_on
QMAKE_CFLAGS += $$QMAKE_CFLAGS_WARN_ON
QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_WARN_ON
QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_OBJECTIVE_CFLAGS_WARN_ON@
You now still have all warnings, but they are part of the CXXFLAGS. Anything you append will now effectively inhibit warnings.
that is a quite impressive find, thanks for sharing!