Search code examples
c++gccqt5c++17qmake

Tell QMake -std=C++17. QMAKE_CXXFLAGS overridden


I use Qt 5.9.1 and all works fine. Except of one little nuisance: it overrides my -std=C++17.

The project:

#CONFIG += c++14 #makes -std=gnu++1y 
#CONFIG += c++17  # is not supported by Qt591
QMAKE_CXXFLAGS += -std=c++17
TARGET = equipment
TEMPLATE = app
SOURCES += ....
....

Compile instructions:

g++ -c -pipe -std=c++17 -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC
-DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_SERIALPORT_LIB -DQT_CORE_LIB  
-I../app -I/opt/Qt5.9.1/5.9.1/gcc_64/include -I/opt/Qt5.9.1/5.9.1/gcc_64
/include/QtCore -I. -I/opt/Qt5.9.1/5.9.1/gcc_64/mkspecs/linux-g++ 
-o test0.o ../test0.cc

We can see two -std= and the second -std=gnu++11 by QMake overrides mine first -std=c++17.

How can I tell QMake to use -std=C++17?


Solution

  • Try CONFIG += c++1z and if it doesn't work pass it to compiler with QMAKE_CXXFLAG.