qmake has a system for persistent configuration, which allows you to set a property in qmake once, and query it each time qmake is invoked. You can set a property in qmake as follows:
qmake -set PROPERTY VALUE
The appropriate property and value should be substituted for
You can retrieve this information back from qmake as follows:
qmake -query PROPERTY qmake -query #queries all current PROPERTY/VALUE pairs
qmake -query lists built-in properties in addition to the properties that you set with
qmake -set PROPERTY VALUE.
This information will be saved into a QSettings object (meaning it will be stored in different places for different platforms).
The following list summarizes the
mkspecthat is resolved and stored in the QMAKESPEC variable during a host build
mkspecthat is resolved and stored in the QMAKESPEC variable during a target build
For example, you can query the installation of Qt for this version of qmake with the
qmake -query "QT_INSTALL_PREFIX"
You can query the values of properties in a project file as follows:
QMAKE_VERS = $$[QMAKE_VERSION]
qmake requires a platform and compiler description file which contains many default values used to generate appropriate Makefiles. The standard Qt distribution comes with many of these files, located in the
mkspecs subdirectory of the Qt installation.
QMAKESPEC environment variable can contain any of the following:
qmake.conffile. In this case qmake will open the
qmake.conffile from within that directory. If the file does not exist, qmake will exit with an error.
mkspecssubdirectory of the data path specified when Qt was compiled (see QLibraryInfo::DataPath).
QMAKESPEC path will be automatically added to the generated Makefile after the contents of the INCLUDEPATH system variable.
The cache file is a special file qmake reads to find settings not specified in the
qmake.conf file, project files, or at the command line. When qmake is run, it looks for a file called
.qmake.cache in parent directories of the current directory, unless you specify
-nocache. If qmake fails to find this file, it will silently ignore this step of processing.
If qmake finds a
.qmake.cache file then it will process this file first before it processes the project file.
Under normal circumstances qmake will try to use appropriate file extensions for your platform. However, it is sometimes necessary to override the default choices for each platform and explicitly define file extensions for qmake to use. This is achieved by redefining certain built-in variables. For example, the extension used for moc files can be redefined with the following assignment in a project file:
QMAKE_EXT_MOC = .mymoc
The following variables can be used to redefine common file extensions recognized by qmake:
All of the above accept just the first value, so you must assign to it just one value that will be used throughout your project file. There are two variables that accept a list of values:
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.