Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qmake: how to remove compiler flag for a certain project, without changing qmake.conf?

I'm using qmake and Visual Studio. In release build qmake adds /GL and /O2 flags to all projects, and I need to remove those two flags for certain libraries within my whole Qt project. Is there a way?

like image 803
Violet Giraffe Avatar asked Nov 23 '11 11:11

Violet Giraffe


4 Answers

I had a similar problem and I solved it by adding the following directive in the .pro file:

QMAKE_CXXFLAGS_RELEASE -= -g

Observe the _RELEASE suffix, otherwise don't work.

like image 57
Gerard Torrent Avatar answered Oct 26 '22 09:10

Gerard Torrent


If -= does not work

try in your .pro file

QMAKE_CFLAGS = $$replace(QMAKE_CFLAGS, "-GL ", "")
QMAKE_CFLAGS = $$replace(QMAKE_CFLAGS, "-O2 ", "")
like image 35
최우석 Avatar answered Oct 26 '22 08:10

최우석


I edited my .pro file by using this, and it worked!

QMAKE_CXXFLAGS_RELEASE  -= -Zc:strictStrings
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -= -Zc:strictStrings

It does not work:

QMAKE_CFLAGS_RELEASE -= -Zc:strictStrings
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO -= -Zc:strictStrings

You can try:

QMAKE_CXXFLAGS_RELEASE  -= -GL -O2
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO -= -GL -O2

Take a look in:

your Qt dir\compiler\mkspecs\win32-msvc2013\qmake.conf

like image 33
Thiago Falcao Avatar answered Oct 26 '22 10:10

Thiago Falcao


The only way this could work is

QMAKE_CFLAGS -= /GL /O2

but I doubt this works for QMAKE_CFLAGS.

Alternatively, you could redefine QMAKE_CFLAGS, forgetting its previous value:

QMAKE_CFLAGS = $$CFLAGS_WITHOUT_GL_O2
like image 40
rubenvb Avatar answered Oct 26 '22 08:10

rubenvb