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 ​​PROPERTY​​​ and ​​VALUE​​.

You can retrieve this information back from qmake as follows:


qmake -query PROPERTY qmake -query #queries all current PROPERTY/VALUE pairs


Note: ​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 ​​built-in​​ properties:

  • QMAKE_SPEC - the shortname of the host​​mkspec​​​ that is resolved and stored in the​​QMAKESPEC​​ variable during a host build
  • QMAKE_VERSION - the current version of qmake
  • QMAKE_XSPEC - the shortname of the target​​mkspec​​​ that is resolved and stored in the​​QMAKESPEC​​ variable during a target build
  • QT_HOST_BINS - location of host executables
  • QT_HOST_DATA - location of data for host executables used by qmake
  • QT_HOST_PREFIX - default prefix for all host paths
  • QT_INSTALL_ARCHDATA - location of general architecture-dependent Qt data
  • QT_INSTALL_BINS - location of Qt binaries (tools and applications)
  • QT_INSTALL_CONFIGURATION - location for Qt settings. Not applicable on Windows
  • QT_INSTALL_DATA - location of general architecture-independent Qt data
  • QT_INSTALL_DOCS - location of documentation
  • QT_INSTALL_EXAMPLES - location of examples
  • QT_INSTALL_HEADERS - location for all header files
  • QT_INSTALL_IMPORTS - location of QML 1.x extensions
  • QT_INSTALL_LIBEXECS - location of executables required by libraries at runtime
  • QT_INSTALL_LIBS - location of libraries
  • QT_INSTALL_PLUGINS - location of Qt plugins
  • QT_INSTALL_PREFIX - default prefix for all paths
  • QT_INSTALL_QML - location of QML 2.x extensions
  • QT_INSTALL_TESTS - location of Qt test cases
  • QT_INSTALL_TRANSLATIONS - location of translation information for Qt strings
  • QT_SYSROOT - the sysroot used by the target build environment
  • ​QT_VERSION​​ - the Qt version. We recommend that you query Qt module specific version numbers by using $$QT.<module>.version variables instead.

For example, you can query the installation of Qt for this version of qmake with the ​​QT_INSTALL_PREFIX​​ property:


qmake -query "QT_INSTALL_PREFIX"


You can query the values of properties in a project file as follows:


QMAKE_VERS = $$[QMAKE_VERSION]


 

The special ​​$$[...]​​ operator can be used to access qmake properties:


message(Qt version: $$[QT_VERSION]) message(Qt is installed in $$[QT_INSTALL_PREFIX]) message(Qt resources can be found in the following locations:) message(Documentation: $$[QT_INSTALL_DOCS]) message(Header files: $$[QT_INSTALL_HEADERS]) message(Libraries: $$[QT_INSTALL_LIBS]) message(Binary files (executables): $$[QT_INSTALL_BINS]) message(Plugins: $$[QT_INSTALL_PLUGINS]) message(Data files: $$[QT_INSTALL_DATA]) message(Translation files: $$[QT_INSTALL_TRANSLATIONS]) message(Settings: $$[QT_INSTALL_CONFIGURATION]) message(Examples: $$[QT_INSTALL_EXAMPLES])