Qbs Manual

Qbs 1.16.0

# 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
- hostArchitecture : string
- 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 : string
- 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"`.

##### Supported Processor Architectures

This table describes the possible values of the architecture property:

Architecture | Description
--- | ---
`"78k"` | 16- and 8-bit accumulator-based register-bank CISC architecture microcontroller family manufactured by Renesas Electronics
`"arm"` | 32-bit RISC architecture for computer processors developed by Acorn RISC Machine Note: There are a lot of sub-variants of the ARM architecture. Some specialized Qbs modules differentiate between them, making use of values such as `"armv7a"`. Please consult the respective module-specific documentation for information on what kind of value to use.
`"arm64"` | 64-bit RISC architecture for computer processors developed by Acorn RISC Machine
`"avr"` | 8-bit modified Harvard RISC architecture microcontroller family manufactured by Microchip Technology
`"avr32"` | 32-bit RISC architecture microcontroller family developed by Atmel
`"ia64"` | 64-bit ISA architecture of the Itanium family processors developed by Intel
"mcs51"} | 8-bit Harvard architecture microcontroller family developed by Intel
`"mips"` | 32-bit RISC microprocessor without interlocked pipelined stages architecture developed by MIPS Computer Systems
`"mips64"` | 64-bit RISC microprocessor without interlocked pipelined stages architecture developed by MIPS Computer Systems
`"msp430"` | 16-bit mixed-signal microcontroller family manufactured by Texas Instruments
`"ppc"` | 32-bit RISC architecture processor family developed by Apple–IBM–Motorola alliance
`"ppc64"` | 64-bit RISC architecture processor family developed by Apple–IBM–Motorola alliance
`"rh850"` | 32-bit automotive microcontroller family manufactured by Renesas Electronics
`"rl78"` | 16- and 8-bit accumulator-based register-bank CISC architecture with 3-stage instruction pipelining microcontroller family manufactured by Renesas Electronics
`"rx"` | High performance 32-bit CISC microcontroller family manufactured by Renesas Electronics
`"s390x"` | 64- and 32-bit System/390 processor architecture developed by IBM
`"sparc"` | 32-bit RISC architecture processor family developed by Sun Microsystems and Fujitsu
`"sparc64"` | 64-bit RISC architecture processor family developed by Sun Microsystems and Fujitsu
`"stm8"` | 8-bit microcontroller family manufactured by STMicroelectronics
`"v850"` | 32-bit RISC microcontroller family manufactured by Renesas Electronics
`"x86"` | 32-bit ISA architecture processor family developed by Intel
`"x86_64"` | 64-bit ISA architecture processor family developed by AMD

Default: Undefined

architectures : stringList

The architectures the product will be built for.

Default: Undefined

This property was introduced in Qbs 1.9.

buildVariant : string

The name of the build variant for the current build.

Possible values are `"debug"`, `"release"` and `"profiling"`. A debug build usually contains additional debug symbols that are needed for debugging the application and has optimizations turned off. A profiling build usually contains debug symbols and has optimizations turned on. This is useful for profiling tools or when you need to retain debug symbols in a release build. A release build is a build without debug information and with optimizations enabled.

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

buildVariants : stringList

The build variants the product will be built for.

Default: Undefined

This 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 property was introduced in Qbs 1.6.

debugInformation : bool

Whether to generate debug information.

Default: `true` if qbs.buildVariant is `"debug"` or `"profiling"`. Otherwise `false`.

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 or profiling builds.

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

hostArchitecture : string

Contains the host OS architecture.

Default: Determined automatically.

This property was introduced in Qbs 1.16.

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 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 property was introduced in Qbs 1.2.

[read-only] hostOSVersionMajor : int

The host operating system major version.

Default: `hostOSVersionParts[0]`

This property was introduced in Qbs 1.2.

hostOSVersionMinor : int

The host operating system minor version.

Default: `hostOSVersionParts[1]`

This 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 property was introduced in Qbs 1.2.

[read-only] hostOSVersionPatch : int

The host operating system patch level.

Default: `hostOSVersionParts[2]`

This property was introduced in Qbs 1.2.

hostPlatform : string

Contains the host OS platform.

Default: Determined automatically.

This property was introduced in Qbs 1.11.

See also hostArchitecture.

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: `"/usr/local"` on Unix, `""` otherwise

This 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 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 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 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"` if qbs.buildVariant is `"debug"`. Otherwise `"fast"`.

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 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 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

[read-only] targetOS : stringList

Contains the list of string values describing the OS and OS family that is used to build a project.

This property is calculated based on the targetPlatform property and is typically used to test for a particular OS or OS family in conditionals:

      Group {
          // Includes all Unix-like platforms, such as: Linux, BSD, Apple platforms and others.
          condition: qbs.targetOS.contains("unix")
          files: ...
      }
      Group {
          // Includes all Apple platforms, such as macOS, iOS, and iOS Simulator.
          condition: qbs.targetOS.contains("darwin")
          files: ...
      }
      Group {
          // Includes only macOS
          condition: qbs.targetOS.contains("macos")
          files: ...
      }

Avoid using targetPlatform for this purpose. 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")

For the complete list of possible values, see Relation between targetPlatform and targetOS.

Default: Undefined

targetPlatform : string

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).

For example, a profile used for building for the iOS Simulator platform will have this property set to the `ios-simulator` value:

      profiles.xcode-iphonesimulator.qbs.targetPlatform: "ios-simulator"

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.

##### Relation between targetPlatform and targetOS

This table describes the possible values and matching between the `targetPlatform` and the targetOS properties:

Target Platform | Target OS
--- | ---
`"aix"` | `["aix", "unix"]`
`"android"` | `["android", "linux", "unix"]`
`"freebsd"` | `["freebsd", "bsd", "unix"]`
`"haiku"` | `["haiku"]`
`"hpux"` | `["hpux", "unix"]`
`"hurd"` | `["hurd", "unix"]`
`"integrity"` | `["integrity", "unix"]`
`"ios"` | `["ios", "darwin", "bsd", "unix"]`
`"ios-simulator"` | `["ios-simulator", "ios", "darwin", "bsd", "unix"]`
`"linux"` | `["linux", "unix"]`
`"lynx"` | `["lynx"]`
`"macos"` | `["macos", "darwin", "bsd", "unix"]`
`"netbsd"` | `["netbsd", "bsd", "unix"]`
`"openbsd"` | `["openbsd", "bsd", "unix"]`
`"qnx"` | `["qnx", "unix"]`
`"solaris"` | `["solaris", "unix"]`
`"tvos"` | `["tvos", "darwin", "bsd", "unix"]`
`"tvos-simulator"` | `["tvos-simulator", "tvos", "darwin", "bsd", "unix"]`
`"unix"` | `["unix"]`
`"vxworks"` | `["vxworks"]`
`"watchos"` | `["watchos", "darwin", "bsd", "unix"]`
`"watchos-simulator"` | `["watchos-simulator", "watchos", "darwin", "bsd", "unix"]`
`"windows"` | `["windows"]`
`undefined` | `[]`

Default: Undefined

This property was introduced in Qt 1.11.

See also Target Platforms.

toolchain : stringList

Contains the list of string values describing the toolchain and toolchain family that is used to build a project.

This property is deduced from the toolchainType property and is typically used to test for a particular toolchain or toolchain family in conditionals:

      Properties {
          // flags for GCC
          condition: qbs.toolchain.contains("gcc")
          cpp.commonCompilerFlags: ...
      }
      Properties {
          // flags for MSVC
          condition: qbs.toolchain.contains("msvc")
          cpp.commonCompilerFlags: ...
      }

Unlike toolchainType, which contains a single value, `qbs.toolchain` is a string list which also contains the toolchain family. This allows to make conditions and checks simpler. For example, instead of:

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

use:

      qbs.toolchain.contains("gcc")

since XCode, GCC and Clang belong to the `"gcc"` family.

##### Relation between toolchainType and toolchain

This table describes the possible values and matching between the toolchainType and the `toolchain` properties:

Toolchain Type | Toolchain
--- | ---
`"clang"` | `["clang", "llvm", "gcc"]`
`"clang-cl"` | `["clang-cl", "msvc"]`
`"gcc"` | `["gcc"]`
`"iar"` | `["iar"]`
`"keil"` | `["keil"]`
`"llvm"` | `["llvm", "gcc"]`
`"mingw"` | `["mingw", "gcc"]`
`"msvc"` | `["msvc"]`
`"sdcc"` | `["sdcc"]`
`"xcode"` | `["xcode", "clang", "llvm", "gcc"]`

Default: Undefined

toolchainType : string

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

For example, to build a project using the `"clang"` toolchain, simply do

      qbs build qbs.toolchainType:clang

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.

Typical values include: `"gcc"`, `"clang"`, `"clang-cl"`, `"mingw"`, `"msvc"`, and `"xcode"`. Also see Relation between toolchainType and toolchain.

By default, `qbs.toolchainType` is automatically detected based on the targetOS property:

Target OS | Toolchain
--- | ---
`"darwin"` | `"xcode"`
`"freebsd"` | `"clang"`
`"haiku"` | `"gcc"`
`"qnx"` | `"qcc"`
`"unix"` | `"gcc"`
`"vxworks"` | `"gcc"`
`"windows"` | `"msvc"`

Default: Determined automatically.

This 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 property was introduced in Qbs 1.4.1.

[read-only] versionMajor : int

The major version number of Qbs.

This property was introduced in Qbs 1.4.1.

[read-only] versionMinor : int

The minor version number of Qbs.

This property was introduced in Qbs 1.4.1.

[read-only] versionPatch : int

The patch version number of Qbs.

This property was introduced in Qbs 1.4.1.