Game Programming using Qt 5 Beginner's Guide
上QQ阅读APP看书,第一时间看更新

What just happened?

How exactly was the project built? To see which kit and which build configuration was used, click on the icon in the action bar directly over the green triangle icon to open the build configuration popup, as shown in the following screenshot:

The exact content that you get varies depending on your installation, but in general, on the left, you will see the list of kits configured for the project and on the right, you will see the list of build configurations defined for that kit. You can click on these lists to quickly switch to a different kit or a different build configuration. If your project is configured only for one kit, the list of kits will not appear here.

What if you want to use another kit or change how exactly the project is built? As mentioned earlier, this is done in the Projects mode. If you go to this mode by pressing the Projects button on the left panel, Qt Creator will display the current build configuration, as shown in the following screenshot:

The left part of this window contains a list of all kits. Kits that are not configured to be used with this project are displayed in gray color. You can click on them to enable the kit for the current project. To disable a kit, choose the Disable Kit option in its context menu.

Under each enabled kit, there are two sections of the configuration. The Build section contains settings related to building the project:

  • Shadow build is a build mode that places all temporary build files in a separate build directory. This allows you to keep the source directory clean and makes your source files easier to track (especially if you use a version control system). This mode is enabled by default.
  • Build directory is the location of temporary build files (only if shadow build is enabled). Each build configuration of the project needs a separate build directory.
  • The Build steps section displays commands that will be run to perform the actual building of the project. You can edit command-line arguments of the existing steps and add custom build steps. By default, the build process consists of two steps: qmake (Qt's project management tool described in the previous chapter) reads the project's .pro file and produces a makefile, and then some variation of make tool (depending on the platform) reads the makefile and executes Qt's special compilers, the C++ compiler, and the linker. For more information about qmake, look up the qmake Manual in the documentation index.
  • The Build environment section allows you to view and change environment variables that will be available to the build tools.
Most variations of the  make tool (including mingw32-make) accept the  -j num_cores command-line argument that allows make to spawn multiple compiler processes at the same time. It is highly recommended that you set this argument, as it can drastically reduce compilation time for big projects. To do this, click on Details at the right part of the Make build step and input -j num_cores to the Make arguments field (replace num_cores with the actual number of processor cores on your system). However, MSVC nmake does not support this feature. To fix this issue, Qt provides a replacement tool called jom that supports it.

There can be multiple build configurations for each kit. By default, three configurations are generated: Debug (required for the debugger to work properly), Profile (used for profiling), and Release (the build with more optimizations and no debug information).

The Run section determines how the executable produced by your project will be started. Here, you can change your program's command-line arguments, working directory, and environment variables. You can add multiple run configurations and switch between them using the same button that allows you to choose the current kit and build configuration.

In most cases for desktop and mobile platforms, the binary release of Qt you download from the web page is sufficient for all your needs. However, for embedded systems, especially for ARM-based systems, there is no binary release available, or it is too heavy resource wise for such a lightweight system. Fortunately, Qt is an open source project, so you can always build it from sources. Qt allows you to choose the modules you want to use and has many more configuration options. For more information, l ook up  Building Qt Sources  in the documentation index.