Qbs Manual

Qbs 1.13.1

# qbs

Comprises general properties. More...

Since: | Qbs 1.0

- List of all members, including inherited members

## Properties

- architecture : string
- architectures : stringList
- buildVariant : string
- buildVariants : stringList
- configurationName : string
- debugInformation : bool
- enableDebugCode : bool
- hostOS : stringList
- hostOSBuildVersion : string
- hostOSVersion : string
- hostOSVersionMajor : int
- hostOSVersionMinor : int
- hostOSVersionParts : list
- hostOSVersionPatch : int
- hostPlatform : string
- install : bool
- installDir : string
- installPrefix : string
- installRoot : string
- installSourceBase : string
- nullDevice : string
- optimization : string
- pathListSeparator : string
- profiles : stringList
- shellPath : path
- sysroot : string
- targetOS : stringList
- targetPlatform : stringList
- toolchain : stringList
- toolchainType : string
- version : string
- versionMajor : int
- versionMinor : int
- versionPatch : int

## Detailed Description

The `qbs` module is implicitly loaded in every product. It contains properties of the current build environment, independent of the used programming languages and toolchains.

### Installation Properties

Typically, you use Group items to specify the target directories for installing files. To install a group of files, set the qbs.install property of the Group to `true`. The value of qbs.installDir specifies the path to the directory where the files will be installed. You can specify a base directory for all installation directories as the value of qbs.installPrefix.

For example, the following properties specify where a set of QML files and an application executable are installed on Windows and Linux:

      Application {
          name: "myapp"
          Group {
              name: "Runtime resources"
              files: "*.qml"
              qbs.install: true
              qbs.installDir: condition: qbs.targetOS.contains("unix")
                  ? "share/myapp" : "resources"
          }
          Group {
              name: "The App itself"
              fileTagsFilter: "application"
              qbs.install: true
              qbs.installDir: "bin"
          }
          qbs.installPrefix: condition: qbs.targetOS.contains("unix")
              ? "usr/local" : "MyApp"
      }

On Windows, the QML files will ultimately get installed in `MyApp\resources` and the application executable in `MyApp\bin`, for instance under `C:\Program Files`. On Linux, the QML files will be installed in `/usr/local/share/myapp` and the executable in `/usr/local/bin`.

By default, qbs.installRoot creates the `install-root` directory in the build directory for packaging the binaries before installation. It is a temporary directory that is usually not available when the application is run, and it should therefore not be set in the project files. You can override the default value from the command line, as described in Installing Files.

### Multiplexing Properties

The following properties are specific to product multiplexing:

- architectures
- buildVariants
- profiles

## Property Documentation

architecture : string

The target platform's processor architecture.

`undefined` indicates that the target platform is architecture-independent (for example the CLR or JVM).

This property is typically set in a profile.

Commonly used values are: `"x86"`, `"x86_64"`, and `"arm"`.

Default: Undefined

architectures : stringList

The architectures the product will be built for.

Default: `["armv5te"]` on Android, same as Xcode on Apple platforms, otherwise equivalent to [qbs.architecture].

This QML property was introduced in Qbs 1.9.

buildVariant : string

The name of the build variant for the current build.

Possible values are `"debug"` and `"release"`. A debug build usually contains additional debug symbols that are needed for debugging the application but that can be left out from the release version. Debug builds are used for testing and release builds for creating the final installation file.

Default: `"release"` if qbs.configurationName is `"release"`. Otherwise `"debug"`

buildVariants : stringList

The build variants the product will be built for.

Default: Equivalent to [qbs.buildVariant].

This QML property was introduced in Qbs 1.9.

[read-only] configurationName : string

The name of the current build configuration.

The build configuration is set via the command line parameter `config`. For more information, see build.

Default: `"default"`

This QML property was introduced in Qbs 1.6.

debugInformation : bool

Whether to generate debug information.

Default: `true` for debug builds, `false` otherwise.

enableDebugCode : bool

Whether to enable debug functionality in the product. Not to be confused with generation of debug symbols or the code optimization level.

The property changes the following things when enabled:

- Passes a flag to the Windows linker to link against a debug Windows CRT (common runtime) library (for example /MTd instead of /MT)

The property changes the following things when disabled:

- Passes the `NDEBUG` define to the compiler

Typically, this property is enabled for debug builds and disabled for release builds.

Default: `true` for debug builds, `false` otherwise.

hostOS : stringList

This property is set by Qbs internally and specifies the OS Qbs is running on.

The possible values for this property are the values of targetOS, even though some of them may not be supported.

Default: Undefined

[read-only] hostOSBuildVersion : string

The host operating system's build version. Currently, only defined for Windows and Apple platforms.

On Windows, this is the 4 or 5 digit Windows build number and is equivalent to versionPatch. On Apple platforms, this is a standard build number in the Apple versioning scheme. For example, `"13C64"`.

Default: Undefined

This QML property was introduced in Qbs 1.2.

[read-only] hostOSVersion : string

The host operating system version. Currently, only defined for Windows and Apple platforms.

Consists of two or three numbers separated by dots. For example, `"10.9"` or `"6.3.9600"`.

Default: Undefined

This QML property was introduced in Qbs 1.2.

[read-only] hostOSVersionMajor : int

The host operating system major version.

Default: `hostOSVersionParts[0]`

This QML property was introduced in Qbs 1.2.

hostOSVersionMinor : int

The host operating system minor version.

Default: `hostOSVersionParts[1]`

This QML property was introduced in Qbs 1.2.

[read-only] hostOSVersionParts : list

The host operating system version as a list.

For example, Windows 8.1 (version 6.3.9600) would correspond to a value of `[6, 3, 9600]`.

Default: `[]`

This QML property was introduced in Qbs 1.2.

[read-only] hostOSVersionPatch : int

The host operating system patch level.

Default: `hostOSVersionParts[2]`

This QML property was introduced in Qbs 1.2.

hostPlatform : string

Do not use this property.

Default: Determined automatically.

This QML property was introduced in Qbs 1.11.

install : bool

Whether to install a certain set of files.

This property is typically set in a Group item to mark a number of files as installable.

Note: Artifacts for which this property is enabled automatically receive the file tag `"installable"`. This is useful for writing packaging-related rules.

Default: `false`

installDir : string

The installation directory for the files of a product or a Group.

The value of this property is a path that is relative to installPrefix.

Default: Undefined

installPrefix : string

The global installation prefix. It is implicitly prepended to all values of installDir.

The value of this property itself is relative to the installRoot in the context of installation.

Default: `[]`

This QML property was introduced in Qbs 1.1.

installRoot : string

The global installation root. It is implicitly prepended to all values of installPrefix in the context of installation.

Note: This property is fundamentally different from installDir and installPrefix in that it must not be visible to the code being built. In fact, the install root is often just a temporary location used to package the binaries, which should therefore not assume they will be in that location at run-time. For the same reason, this property is usually not set from within project files.

Default: `<build dir>/install-root`

This QML property was introduced in Qbs 1.4.

installSourceBase : string

The base directory of the local files that are going to be installed. The source base directory is omitted from the target directory path specified in installDir.

Default: The directory of the current file to be installed, relative to the product's source directory.

This QML property was introduced in Qbs 1.4.

nullDevice : string

The platform-specific file path corresponding to the null device.

Default: `"NUL"` on Windows, `"/dev/null"` on Unix.

This QML property was introduced in Qbs 1.4.2.

optimization : string

The general type of optimization that should be performed by all toolchains.

Allowed values are:

- `"fast"`
- `"none"`
- `"small"`

Default: `"none"` for debug builds, `"fast"` for release builds.

pathListSeparator : string

The platform-specific separator for a path list that is used in environment variables or other contexts.

Default: `";"` on Windows, `":"` on Unix.

profiles : stringList

The profiles for which the product should be built.

For each profile listed here, one instance of the product will be built according to the properties set in the respective profile.

Default: [project.profile]

This QML property was introduced in Qbs 1.9.

shellPath : path

The platform-specific file path corresponding to the command line interpreter.

On Windows, this is the path to `cmd.exe`, which is held in the `COMSPEC` environment variable (typically, `C:/Windows/System32/cmd.exe`), On Unix-like platforms, this is `/bin/sh`.

Default: `"%COMSPEC%"` on Windows, `"/bin/sh"` on Unix

This QML property was introduced in Qbs 1.5.

sysroot : string

The `sysroot` of the target platform.

This property is typically set in a profile for cross-compiling.

Default: Undefined

targetOS : stringList

Specifies the OS you want to build the project for.

Use this property to test for a particular OS or OS family in conditionals. Do not use targetPlatform for this purpose.

Possible values include one or more of `"bsd"`, `"darwin"`, and `"unix"`, in addition to the possible values of targetPlatform.

Default: Undefined

targetPlatform : stringList

The OS you want to build the project for.

This property is typically set in a profile or for a particular product where the target OS is always known (such as an Apple Watch app written in native code).

You should generally treat this property as write-only and avoid using it to test for the current target OS. Instead, use the targetOS property for conditionals. For example, instead of:

      qbs.targetPlatform === "macos" || qbs.targetPlatform === "ios" || qbs.targetPlatform === "tvos" || qbs.targetPlatform === "watchos"

use

      qbs.targetOS.contains("darwin")

However, in some cases using `targetPlatform` would be acceptable, such as when the resulting condition would be simpler while still being correct:

      qbs.targetPlatform === "linux"

versus

      qbs.targetOS.contains("linux") && !qbs.targetOS.contains("android")

The possible values include one or more of the following:

- `"aix"`
- `"android"`
- `"freebsd"`
- `"haiku"`
- `"hpux"`
- `"hurd"`
- `"integrity"`
- `"ios"`
- `"ios-simulator"`
- `"linux"`
- `"lynx"`
- `"macos"`
- `"netbsd"`
- `"openbsd"`
- `"qnx"`
- `"solaris"`
- `"tvos"`
- `"tvos-simulator"`
- `"vxworks"`
- `"watchos"`
- `"watchos-simulator"`
- `"windows"`

Default: Undefined

This QML property was introduced in Qt 1.11.

toolchain : stringList

The attributes of the toolchain that is going to be used for this build.

Typical values include `"llvm"`, in addition to the possible values of toolchainType.

Default: Undefined

toolchainType : string

The toolchain that is going to be used for this build.

You should generally treat this property as write-only and avoid using it to test for the current toolchain. Instead, use the toolchain property for conditionals.

For example, instead of:

      (qbs.toolchainType === "xcode" || qbs.toolchainType === "clang" || qbs.toolchainType === "gcc")

use:

      qbs.toolchain.contains("gcc")

However, there are some cases when using `toolchainType` would be acceptable, such as when the resulting condition would be simpler while still being correct:

      (qbs.toolchainType === "gcc")

versus:

      (qbs.toolchain.contains("gcc") && !qbs.toolchain.contains("clang"))

Typical values include: `"gcc"`, `"clang"`, `"mingw"`, `"msvc"`, and `"xcode"`.

Default: Determined automatically.

This QML property was introduced in Qbs 1.11.

[read-only] version : string

The version number of Qbs as a string. For example, `"1.4.1"`.

This QML property was introduced in Qbs 1.4.1.

[read-only] versionMajor : int

The major version number of Qbs.

This QML property was introduced in Qbs 1.4.1.

[read-only] versionMinor : int

The minor version number of Qbs.

This QML property was introduced in Qbs 1.4.1.

[read-only] versionPatch : int

The patch version number of Qbs.

This QML property was introduced in Qbs 1.4.1.