How to specify compiler flag in one source file with qmake?

While other source files use flags by default? Some of my source files need some additional C ++ preprocessors. I am using Qt 5. I only found QMAKE_CXXFLAGS for global use in qmake projects.

+5
source share
1 answer

This is what was previously done in theory for drawing a GUI 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 extended use in the documentation on how to add a compiler:

Custom compiler specifications support the following elements:

Member Description

teams . Commands used to generate output from input.

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

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

dependency_type Defines the type of file on which the output is located. If it is a known type (such as TYPE_C, TYPE_UI, TYPE_QRC), it is treated as one of these file types.

depends Specifies the dependencies of the output file.

input A variable that indicates the files to be processed using a custom compiler.

name Description of what the custom compiler does. This is used only in some backends.

output The name of the file created from the custom compiler.

output_function Defines a custom qmake function that is used to specify the name of the file to be created.

variables Indicates that the variables specified here are replaced with $ (QMAKE_COMP_VARNAME) if the value $ (VARNAME) is specified in the pro file.

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

+4
source

Source: https://habr.com/ru/post/1210024/


All Articles