Qbs Manual | Product Item

Qbs 1.10.1

Probe Item ◦ Profile Item

# 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

Property | Type | Default | Description
--- | --- | --- | ---
builtByDefault | bool | true | If 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.
condition | bool | true | If false, the product will not be built.
name | string | empty string | The 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.
type | stringList | empty list | The file tags matching the product's target artifacts.
targetName | string | `name` with illegal file name characters replaced by underscores | The base file name of the product's target artifacts.
destinationDirectory | string | product.buildDirectory | The directory where the target artifacts will be located. If a relative path is given, the base directory will be `project.buildDirectory`.
files | stringList | empty list | A 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.
excludeFiles | stringList | empty list | A list of source files not to include. Useful with wildcards. For more information, see Group Item.
consoleApplication | bool | linker-dependent | If 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.
qbsSearchPaths | stringList | project.qbsSearchPaths | See 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.
version | string | undefined | The 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.

Property | Type | Default | Description
--- | --- | --- | ---
aggregate | bool | `undefined` | If `true`, an aggregate product will be created that has dependencies on all multiplex instances of this product.
multiplexedType | stringList | `undefined` | Specifies the product type for the multiplexed product instances.
multiplexByQbsProperties | stringList | `["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:

Property | Type | Description
--- | --- | ---
buildDirectory | path | The build directory for this product. This is the directory where generated files are placed.
sourceDirectory | path | The source directory for this product. This is the directory of the file where this product is defined.

Probe Item ◦ Profile Item