[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?

  • Moderators

    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.

  • Moderators

    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

    You now still have all warnings, but they are part of the CXXFLAGS. Anything you append will now effectively inhibit warnings.

  • Moderators

    that is a quite impressive find, thanks for sharing!

Log in to reply