Search code examples
qtmakefileqmake

How to remove alter default CFLAGS in qmake?


I'm using qmake/make to build a library. At the moment, the build is working but we can't use the resulting library.

qmake generates this Makefile:

CFLAGS        = -Wall -pedantic -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -O2 $(DEFINES)
CXXFLAGS      = -Wall -pedantic -fPIC -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -m64 -mtune=generic -O2 $(DEFINES)

When modifying the Makefile and using those options, it works:

CFLAGS        = -Wall -pedantic -fPIC
CXXFLAGS        = -Wall -pedantic -fPIC

My .pro file contains this informations:

TEMPLATE = lib subdirs
CONFIG = create_prl staticlib
QMAKE_CXXFLAGS = -Wall -pedantic -fPIC
QMAKE_CFLAGS = -Wall -pedantic -fPIC
# and Sources + headers

The question is how can I tell qmake to generate only the flags needed ? (i.e. -Wall -pedantic -fPIC)


Solution

  • I succeed removing all flags using those commands:

    QMAKE_CXXFLAGS_RELEASE = -Wall -pedantic -fPIC
    QMAKE_CFLAGS_RELEASE = -Wall -pedantic -fPIC