The behavior of qmake can be customized when it is run by specifying various options on the command line. These allow the build process to be fine-tuned, provide useful diagnostic information, and can be used to specify the target platform for your project.
The syntax used to run qmake takes the following simple form:
qmake [mode] [options] files
Note: If you installed Qt via a package manager, the binary may be
qmake supports two different modes of operation. In the default mode, qmake uses the information in a project file to generate a Makefile, but it is also possible to use qmake to generate project files. If you want to explicitly set the mode, you must specify it before all other options. The
mode can be either of the following two values:
qmake output will be a Makefile.
qmake output will be a project file.
Note: It is likely that the created file will need to be edited. For example, adding the
QTvariable to suit what modules are required for the project.
You can use the
options to specify both general and mode-specific settings. Options that only apply to the Makefile mode are described in the Makefile Mode Options section, whereas options that influence the creation of project files are described in the Project Mode Options section.
files argument represents a list of one or more project files, separated by spaces.
A wide range of options can be specified on the command line to qmake in order to customize the build process, and to override default settings for your platform. The following basic options provide help on using qmake, specify where qmake writes the output file, and control the level of debugging information that will be written to the console:
qmake will go over these features and give some useful help.
qmake output will be directed to
file. If this option is not specified, qmake will try to use a suitable file name for its output, depending on the mode it is running in.
If '-' is specified, output is directed to stdout.
qmake will output debugging information. Adding
-dmore than once increases verbosity.
The template used for the project is usually specified by the TEMPLATE variable in the project file. You can override or modify this by using the following options:
qmake will override any set
tmpl, but only after the .pro file has been processed.
qmake will add
The level of warning information can be fine-tuned to help you find problems in your project file:
qmake will report all known warnings.
No warning information will be generated by qmake.
qmake will only generate parser warnings. This will alert you to common pitfalls and potential problems in the parsing of your project files.
qmake will warn of common pitfalls and potential problems in your project file. For example, qmake will report multiple occurrences of files in lists and missing files.
qmake -makefile [options] files
In Makefile mode, qmake will generate a Makefile that is used to build the project. Additionally, the following options may be used in this mode to influence the way the project file is generated:
qmake will process assignments given on the command line after the specified files.
qmake will ignore the
qmake will not generate any dependency information.
qmake will use
fileas the cache file, ignoring any other .qmake.cache files found.
qmake will use
specas a path to platform and compiler information, and ignore the value of QMAKESPEC.
You may also pass qmake assignments on the command line. They are processed before all of the files specified. For example, the following command generates a Makefile from test.pro:
qmake -makefile -o Makefile "CONFIG+=test" test.pro
However, some of the specified options can be omitted as they are default values:
qmake "CONFIG+=test" test.pro
If you are certain you want your variables processed after the files specified, then you may pass the
-after option. When this is specified, all assignments on the command line after the
-after option will be postponed until after the specified files are parsed.
qmake -project [options] files
In project mode, qmake will generate a project file. Additionally, you may supply the following options in this mode:
qmake will look through supplied directories recursively.
qmake will not look in your current working directory for source code. It will only use the specified
In this mode, the
files argument can be a list of files or directories. If a directory is specified, it will be included in the DEPENDPATH variable, and relevant code from there will be included in the generated project file. If a file is given, it will be appended to the correct variable, depending on its extension. For example, UI files are added to FORMS, and C++ files are added to SOURCES.
You may also pass assignments on the command line in this mode. When doing so, these assignments will be placed last in the generated project file.
© 2021 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.