SubProject | Qbs Manual
Description: Adds a project from a different file.

- Qbs Manual
- QbsLanguageItems
- SubProject
- Qbs 3.1.1

Scanner

# SubProject

Adds a project from a different file. More...

- List of all members, including inherited members
- SubProject is part of List of All Items.

## Properties

- condition : bool
- filePath : path
- inheritProperties : bool

## Detailed Description

A SubProject item is used to add a sub-project that is defined in a separate file. Additionally, properties of the sub-project can be set without modifying the separate project file.

The following example adds a sub-project defined in `subdir/project.qbs` and overrides its name.

     Project {
         SubProject {
             filePath: "subdir/project.qbs"
             Properties {
                 name: "A sub-project"
             }
         }
         ...
     }

A typical use case for SubProject items is to conditionally include sub-projects. The following example pulls in the tests sub-project if and only if the `withTests` property is `true`.

     Project {
         property bool withTests: false
         SubProject {
             filePath: "tests/tests.qbs"
             Properties {
                 condition: parent.withTests
             }
         }
         ...
     }

If you do not need to set any properties on the sub-project, you can also use the Project.references property, the same way you would for a product.

     Project {
         references: "subdir/project.qbs"
     }

is equivalent with

     Project {
         SubProject {
             filePath: "subdir/project.qbs"
         }
     }

It is also possible to nest Project items directly in the same file.

## Property Documentation

condition : bool

Whether the sub-project is added. If `false`, the sub-project is not included.

Setting this property has the same effect as setting the `condition` property within a Properties item. If both this property and the `condition` property within a Properties item are defined, the sub-project is included only if both properties evaluate to `true`.

Default: `true`

filePath : path

The file path of the project to add as a sub-project. If the top-level item in this file is a Product, it gets wrapped automatically in a new project.

Default: empty

inheritProperties : bool

Determines whether the sub-project should inherit the properties of the surrounding Project. You can use this feature to share global settings between projects and sub-projects.

Default: `true`

Scanner