0

I'm trying to find out how to specify flags for C sources in qmake project. I've tested the three options:

QMAKE_CFLAGS
QMAKE_CPPFLAGS
QMAKE_CXXFLAGS

QMAKE_CFLAGS is what I need. Both CPPFLAGS and CXXFLAGS are only applied to C++ sources. What I'm worried about is that even though CFLAGS works, this option is not documented. It's just not in the list of qmake options: http://qt-project.org/doc/qt-5.0/qtdoc/qmake-variable-reference.html

So, how am I supposed to set C flags then?

On a sidenote, it's also weird there's no single option to set flags for both C and C++.

László Papp
  • 51,870
  • 39
  • 111
  • 135
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
  • instead `QMAKE_CFLAGS` you should use `QMAKE_CFLAGS_DEBUG` or `QMAKE_CFLAGS_RELEASE` it is on the list. – Marek R Sep 16 '13 at 11:26
  • @MarekR: This wasy I have to specify the same flags 3 times -`QMAKE_CFLAGS_DEBUG`, `QMAKE_CFLAGS_RELEASE` and `QMAKE_CPPFLAGS`. Very easy to miss something when editing flags. Is there no better solution? – Violet Giraffe Sep 16 '13 at 11:40
  • 2
    you can create common custom parameter and then reference it, something like: "MY_SETTINGS = -Wall" then "QMAKE_CFLAGS_RELEASE += $$MY_SETTINGS" – Marek R Sep 16 '13 at 12:50
  • @MarekR: good point, thanks. Yay for making my pro files even bigger... – Violet Giraffe Sep 16 '13 at 16:22

1 Answers1

1

Even though QMAKE_CFLAGS is undocumented, it does not mean you cannot use it. There are so many useful variables with qmake undocumented. I would not discourage you to stop using this if you wish.

As for the C and C++ question: I think it is reasonable to set them separately as they are two different languages, but you can always set the same to both by having an interim variables or just duplicating the append statements.

László Papp
  • 51,870
  • 39
  • 111
  • 135