如何使用qmake将编译器标志指定到单个源文件? [英] How to specify compiler flag to a single source file with qmake?

查看:293
本文介绍了如何使用qmake将编译器标志指定到单个源文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

其他源文件是否使用默认标志?我的某些源文件需要一些额外的C ++预处理器定义。我使用Qt5。我只发现QMAKE_CXXFLAGS在qmake项目中供全局使用。

While other source files use the default flags? Some of my source files need some extra C++ preprocessor defines. I use Qt 5. I only found QMAKE_CXXFLAGS is for global use in qmake projects.

推荐答案

Qt源本身中GUI绘画的理论:

This is what used to be done in theory for GUI painting in the Qt source itself:

SOURCES_NOOPTIMIZE = somefile.cpp
nooptimize.name = nooptimize
nooptimize.input = SOURCES_NOOPTIMIZE
nooptimize.dependency_type = TYPE_C
nooptimize.variable_out = OBJECTS
nooptimize.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_IN_BASE}$${first(QMAKE_EXT_OBJ)}
nooptimize.commands = $${QMAKE_CXX} $(CXXFLAGS) -O0 $(INCPATH) -c ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} # Note the -O0
QMAKE_EXTRA_COMPILERS += nooptimize

另请参见高级用法 如何添加编译器:

See also the advanced use in the documentation how to add a compiler:


自定义编译器规范支持以下成员:

Custom compiler specifications support the following members:

成员描述

命令 用于从输入生成输出的命令。

commands The commands used for for generating the output from the input.

CONFIG 自定义编译器的特定配置选项。有关详细信息,请参见CONFIG表。

CONFIG Specific configuration options for the custom compiler. See the CONFIG table for details.

depend_command 指定用于生成输出依赖项列表的命令。

depend_command Specifies a command used to generate the list of dependencies for the output.

dependency_type 指定输出的文件类型。如果它是已知类型(例如TYPE_C,TYPE_UI,TYPE_QRC),则将其视为这些文件类型之一。

dependency_type Specifies the type of file the output is. If it is a known type (such as TYPE_C, TYPE_UI, TYPE_QRC), it is handled as one of those type of files.

取决于 指定输出文件的依赖性。

depends Specifies the dependencies of the output file.

输入 该变量指定应使用自定义文件处理的文件。

input The variable that specifies the files that should be processed with the custom compiler.

名称 有关自定义编译器正在执行的操作的描述。仅在某些后端中使用。

name A description of what the custom compiler is doing. This is only used in some backends.

输出 从自定义编译器创建的文件名。

output The filename that is created from the custom compiler.

output_function 指定一个自定义qmake函数,该函数用于指定要创建的文件名。

output_function Specifies a custom qmake function that is used to specify the filename to be created.

变量 表示在pro文件中将其指定为$(VARNAME)时,此处指定的变量将替换为$(QMAKE_COMP_VARNAME)。

variables Indicates that the variables specified here are replaced with $(QMAKE_COMP_VARNAME) when referred to in the pro file as $(VARNAME).

variable_out 应该将根据输出创建的文件添加到该变量。

variable_out The variable that the files created from the output should be added to.

这篇关于如何使用qmake将编译器标志指定到单个源文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆