开发者

CXXFLAGS modification of Qt pro file? [duplicate]

开发者 https://www.devze.com 2023-03-01 11:13 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: Configuring the GCC compiler switches in Qt, QtCreator, and QMake
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

Configuring the GCC compiler switches in Qt, QtCreator, and QMake

I would like to use -O1 instead of -O2 in my makefile (CFLAGS and CXXFLAGS) for my Linux build. My understanding of how these makefi开发者_如何学Cles are generated based on the .pro file is somewhat lacking. This is because the version of Qt combined with the version of G++ I am using has instabilities when -O2 is present.

Presently, I am running a replacement script, after I run qmake, which does this:

sed -i 's/\-O2/\-O1/g' AllProjects/Makefile.Release

This is a ghetto solution. A much better solution would be to modify the .pro file somehow to pass along these directives. I am not sure how CFLAGS and CXXFLAGS are being generated though.

I have tried passing a

linux-g++-{ 
      CFLAGS += -O1
      CXXFLAGS += -O1
      CONFIG += -O1
}

which did not work.


You were very close. What you want is:

QMAKE_CXXFLAGS += -O1

If you would like to apply flags to just the release build, then you can use this:

QMAKE_CXXFLAGS_RELEASE += -O1

You also probably want to change your condition to be a little more flexible. In summary, something like this:

*-g++* {
    QMAKE_CXXFLAGS += -O1
}

More in the documentation here: http://qt-project.org/doc/qt-5.0/qtdoc/qmake-variable-reference.html#qmake-cxxflags

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号