Configuring builds

Visual Studio uses the Project System to build C++ projects, where MSBuild provides the project file format and build framework. Qt VS Tools integrate with MSBuild, so that you design and build Qt applications as Visual Studio projects. In addition, Visual Studio supports using CMake to build projects.

When you create new Qt application projects, select whether to use MSBuild or CMake to build them. The wizards create the necessary files for you.

{Selecting CMake in the application wizard}

Load .pro files to Visual Studio to continue developing existing Qt application projects that you configured to use qmake.

MSBuild configurations

At very general level, MSBuild works as follows:

  • An MSBuild project consists of references to source files and descriptions of actions for processing those source files that are called targets.
  • The build process runs in the context of a project configuration, such as Debug or Release. A project may contain any number of configurations.
  • Data associated to source files and the project itself is accessible through properties. MSBuild properties are name-value definitions, specified per configuration. That is, each configuration has its own set of property definitions.

{Diagram showing Visual Studio Project and MSBuild}

Properties

Set property values for the project itself (project scope) or for a specific file in the project (file scope), either globally or locally:

  • Project scope properties are always global. For example, the project's output directory or target file name.
  • Properties that apply to source files can be global, in which case the same value applies to all files. For example, set the default compiler warning level globally at level 3.
  • To override such a global, file-scope definition for a specific file define a local property with the same name. For example, compile one of the source files with warning level 4.
  • Global definitions are stored in the project file or imported from property sheet files.
  • Local property definitions are stored in the project file, within the associated source file references.

Qt settings

Qt VS Tools provide the MSBuild project system with a set of Qt-specific targets that describe how to use the appropriate Qt tools to process files such as moc headers.

{Qt Project Settings}

Qt settings are fully-fledged project properties, which ensures that:

  • Changes in Qt settings are synchronized with all the other properties in the project.
  • You can specify Qt settings, such as Qt versions and modules, separately for each build configuration.
  • You can override compiler properties for files that Qt tools generate in project settings
  • To share Qt settings within a team or organization, export and import them to and from shared property sheet files (.props).

See also Add Qt versions, Cross-compile, Load Qt projects, and Building.

© 2024 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.