How to specify separate compilation options for different targets in qmake?

谁说我不能喝 提交于 2019-12-07 02:56:49

问题


Is there any way to specify separate compilation options for different targets in qmake ?

For example:

QMAKE_CXXFLAGS += -O 
SOURCES += file1.cpp    

QMAKE_CXXFLAGS += -std=gnu++0x -O 
SOURCES += file2.cpp

So file1.cpp will be compiled only with -O option and file file2.cpp with -std=gnu++0x -O options.


回答1:


You could create and use a separate "extra compiler", as follows:

# Use the built-in compiler for file1.cpp
QMAKE_CXXFLAGS += -O 
SOURCES += file1.cpp    

# Create a new compiler for file2.cpp
gnupp0x.input = SOURCES_GNUPP0X
gnupp0x.output = ${QMAKE_FILE_BASE}.o
gnupp0x.commands = g++ -std=gnu++0x $$QMAKE_CXXFLAGS ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT}
QMAKE_EXTRA_COMPILERS += gnupp0x

# Use the new compiler for file2.cpp
SOURCES_GNUPP0X += file2.cpp


来源:https://stackoverflow.com/questions/14604242/how-to-specify-separate-compilation-options-for-different-targets-in-qmake

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!