qbs

Comprises general properties. More...

Since: Qbs 1.0

Properties

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:

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


buildVariant : string

The name of the build variant for the current build.

Default: "debug"


buildVariants : stringList

The build variants the product will be built for.

Default: Equivalent to [qbs.buildVariant].

This property was introduced in Qbs 1.9.


configurationName : string

The name of the current build configuration.

Default: "default"

This 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 compile debug code in the product.

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

Do not use this property.

Default: Determined automatically.

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


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


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