qbs
Comprises general properties. More...
Since: | Qbs 1.0 |
Properties
- architecture : string
- architectures : stringList
(since Qbs 1.9)
- buildVariant : string
- buildVariants : stringList
(since Qbs 1.9)
- configurationName : string
(since Qbs 1.6)
- debugInformation : bool
- enableDebugCode : bool
- install : bool
- installDir : string
- installPrefix : string
(since Qbs 1.1)
- installRoot : string
(since Qbs 1.4)
- installSourceBase : string
(since Qbs 1.4)
- optimization : string
- profiles : stringList
(since Qbs 1.9)
- shellPath : path
(since Qbs 1.5)
- sysroot : string
- targetOS : stringList
- targetPlatform : string
(since 1.11)
- toolchain : stringList
- toolchainType : string
(since Qbs 1.11)
- version : string
(since Qbs 1.4.1)
- versionMajor : int
(since Qbs 1.4.1)
- versionMinor : int
(since Qbs 1.4.1)
- versionPatch : int
(since Qbs 1.4.1)
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.includes("unix") ? "share/myapp" : "resources" } Group { name: "The App itself" fileTagsFilter: "application" qbs.install: true qbs.installDir: "bin" } qbs.installPrefix: condition: qbs.targetOS.includes("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"
.
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 |
"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 |
"c166" | 16-bit architecture microcontroller family developed by Infineon |
"cr16" | 16-bit compact RISC architecture microcontroller family developed by National Semiconductor |
"e2k" | 512-bit Russian wide VLIW microprocessor developed by Moscow Center of SPARC Technologies (MCST) and fabricated by TSMC |
"hcs8" | 8-bit HC08 and S08 microcontroller family from Freescale Semiconductor |
"hcs12" | 16-bit HC12 and S12 microcontroller family from Freescale Semiconductor |
"hppa" | 64-bit PA-RISC processor architecture developed by Hewlett-Packard |
"ia64" | 64-bit ISA architecture of the Itanium family processors developed by Intel |
"m16c" | 16-bit CISC microcontrollers featuring high ROM code efficiency manufactured by Renesas Electronics |
"m32c" | 32- and 16-bit CISC microcontrollers featuring high ROM code efficiency manufactured by Renesas Electronics |
"m32r" | 32-bit RISC microcontrollers for general industrial and car-mounted systems, digital AV equipment, digital imaging equipment manufactured by Renesas Electronics |
"m68k" | 16- and 32-bit CISC microprocessor, developed by Motorola Semiconductor Products Sector, and further improved as ColdFire architecture developed by NXP |
"mcs251" | 8-, 16-, and 32-bit microcontroller family which is a next binary compatible generation for the "mcs51" family |
"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 |
"r32c" | 32-bit CISC microcontrollers with improved code efficiency and processing performance manufactured by Renesas Electronics |
"rh850" | 32-bit automotive microcontroller family manufactured by Renesas Electronics |
"riscv" | Open and free standard instruction set architecture based on established RISC principles |
"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 |
"sh" | 32-bit RISC architecture processor family developed by Hitachi and currently manufactured by Renesas Electronics |
"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_16" | 16-bit ISA architecture processor family developed by Intel |
"x86_64" | 64-bit ISA architecture processor family developed by AMD |
"xtensa" | 32-bit architecture with a compact 16- and 24-bit instruction set developed by Tensilica |
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.
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.
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.
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"
.
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 |
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.includes("unix") files: ... } Group { // Includes all Apple platforms, such as macOS, iOS, and iOS Simulator. condition: qbs.targetOS.includes("darwin") files: ... } Group { // Includes only macOS condition: qbs.targetOS.includes("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.includes("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.includes("linux") && !qbs.targetOS.includes("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"] |
"dos" | ["dos"] |
"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"] |
"os2" | ["os2"] |
"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"] |
"none" | ["none"] |
undefined | [] |
Note: The "none" value is usually used for a bare-metal platforms.
Default: Host.platform()
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.includes("gcc") cpp.commonCompilerFlags: ... } Properties { // flags for MSVC condition: qbs.toolchain.includes("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.includes("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"] |
"cosmic" | ["cosmic"] |
"dmc" | ["dmc"] |
"gcc" | ["gcc"] |
"iar" | ["iar"] |
"keil" | ["keil"] |
"llvm" | ["llvm", "gcc"] |
"mingw" | ["mingw", "gcc"] |
"msvc" | ["msvc"] |
"qcc" | ["qcc"] |
"sdcc" | ["sdcc"] |
"watcom" | ["watcom"] |
"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.
version : string |
The version number of Qbs as a string. For example, "1.4.1"
.
This property was introduced in Qbs 1.4.1.
versionMajor : int |
The major version number of Qbs.
This property was introduced in Qbs 1.4.1.
versionMinor : int |
The minor version number of Qbs.
This property was introduced in Qbs 1.4.1.
versionPatch : int |
The patch version number of Qbs.
This property was introduced in Qbs 1.4.1.