Product Item

A product typically represents the result of a build process. It specifies a set of input and output files and a way to transform the former into the latter. For example, the following product sets up a very simple C++ application:

Product {
    name: "helloworld"
    type: "application"
    files: "main.cpp"
    Depends { name: "cpp" }

The type property specifies what will be built (an executable). The files property specifies the input files (one C++ source file), and the Depends item pulls in the logic from the cpp module about how to do the necessary transformations. For some often-used types of products, Qbs pre-defines special derived items that save users some typing. These are:

  • Application
  • CppApplication
  • DynamicLibrary
  • StaticLibrary

Therefore, the above example could also be written like this:

CppApplication {
    name: "helloworld"
    files: "main.cpp"

Any property prop attached to this item is available in sub-items as product.prop, as well as in modules that are loaded from this product.

Product Properties

builtByDefaultbooltrueIf false, the product will only be built if this is explicitly requested, either by listing the product name as an argument to --products or by giving the build command the --all-products option.
conditionbooltrueIf false, the product will not be built.
namestringempty stringThe name of the product. Used to identify the product in a Depends item, for example. The value of this property must be a simple JavaScript expression that does not depend on module properties or values that are non-local to this product.
CppApplication {
    name: "hello" + "world"
    // valid
CppApplication {
    name: "app_" + qbs.targetOS.join("_")
    // invalid

To change the name of your product's target artifact, modify Product.targetName instead.

typestringListempty listThe file tags matching the product's target artifacts.
targetNamestringname with illegal file name characters replaced by underscoresThe base file name of the product's target artifacts.
destinationDirectorystringproduct.buildDirectoryThe directory where the target artifacts will be located. If a relative path is given, the base directory will be project.buildDirectory.
filesstringListempty listA list of source files. Syntactic sugar to save a Group item for simple products. Relative paths are resolved using the parent directory of the project file that sets the property.
excludeFilesstringListempty listA list of source files not to include. Useful with wildcards. For more information, see Group Item.
consoleApplicationboollinker-dependentIf true, a console application is generated. If false, a GUI application is generated. Only takes effect on Windows. This property also influences the default application type on Apple platforms. If true, an application bundle is generated. If false, a normal executable is generated.
qbsSearchPathsstringListproject.qbsSearchPathsSee the documentation of the Project Item property of the same name. The value set here will be merged with the one inherited from the project.
versionstringundefinedThe version number of the product. Used in shared library filenames and generated Info.plist files in Apple application and framework bundles, for example.

The following properties are relevant for product multiplexing only. Unless multiplexing is desired, they can be left at their default values.

Note: We do not promise backwards compatibility for multiplexing properties as they are likely to change in future Qbs versions.

aggregateboolundefinedIf true, an aggregate product will be created that has dependencies on all multiplex instances of this product.
multiplexedTypestringListundefinedSpecifies the product type for the multiplexed product instances.
multiplexByQbsPropertiesstringList["profiles"]Specifies which properties of the qbs module will be used for product multiplexing. Its value must be a subset of ["architectures", "buildVariants", "profiles"].

The following properties are automatically set by Qbs and cannot be changed by the user:

buildDirectorypathThe build directory for this product. This is the directory where generated files are placed.
sourceDirectorypathThe source directory for this product. This is the directory of the file where this product is defined.

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