- Module cpp

# Module cpp

The `cpp` module contains the properties and rules for toolchains of the C/C++ family. On OS X this includes support for Objective-C/C++.

## General Properties

### architecture

Type: | `string`
Default: | `qbs.architecture`

Target architecture. See `qbs.architecture`.

### debugInformation

Type: | `bool`
Default: | `qbs.debugInformation`

Generate debug information. See `qbs.debugInformation`.

### defines

Type: | `stringList`
Default: | `undefined`

List of preprocessor macros that gets passed to the compiler. To set macro values use the following syntax:

    cpp.defines: ["USE_COLORS=1", 'COLOR_STR="blanched almond"']

### platformDefines

Type: | `stringList`
Default: | `undefined`

List of preprocessor macros that are used for all projects that are built for the current target platform. User project files usually do not set this property.

### compilerDefines

Type: | `stringList`
Default: | `undefined`

List of preprocessor macros that are used for all projects that are using the current toolchain. User project files usually do not set this property.

### includePaths

Type: | `pathList`
Default: | `undefined`

List of include paths. Relative paths are considered to be relative to the .qbs product file they are used in.

### systemIncludePaths

Type: | `pathList`
Default: | `undefined`

List of include paths that are passed as system include paths to the compiler. For header files in those paths warnings will be ignored. Relative paths are considered to be relative to the .qbs product file they are used in.

### libraryPaths

Type: | `pathList`
Default: | `undefined`

List of library search paths. Relative paths are considered to be relative to the .qbs product file they are used in.

### dynamicLibraries

Type: | `stringList`
Default: | `undefined`

List of dynamic libraries to be linked. If the library is part of your project, consider using a Depends item instead.

### staticLibraries

Type: | `stringList`
Default: | `undefined`

List of static libraries to be linked. If the library is part of your project, consider using a Depends item instead.

### prefixHeaders

Type: | `pathList`
Default: | `undefined`

List of files to automatically include at the beginning of each source file in the product.

### precompiledHeader

Type: | `path`
Default: | `undefined`

Name of the header file to be precompiled.

If you want to use the same precompiled header for all languages (C, C++, Objective-C and Objective-C++), set this property and ensure that the header contains appropriate ifdefs.

Otherwise, use the `cPrecompiledHeader`, `cppPrecompiledHeader`, `objcPrecompiledHeader` and `objcppPrecompiledHeader` to specify precompiled headers per-language.

### cPrecompiledHeader

Type: | `path`
Default: | `precompiledHeader`

Name of the C header file to be precompiled.

### cxxPrecompiledHeader

Type: | `path`
Default: | `precompiledHeader`

Name of the C++ header file to be precompiled.

### objcPrecompiledHeader

Type: | `path`
Default: | `precompiledHeader`

Name of the Objective-C header file to be precompiled.

### objcxxPrecompiledHeader

Type: | `path`
Default: | `precompiledHeader`

Name of the Objective-C++ header file to be precompiled.

### precompiledHeaderDir

Type: | `path`
Default: | `product.buildDirectory`

The directory that will contain the precompiled header files. Usually you won't need to set this.

### optimization

Type: | `string`
Default: | `qbs.optimization`

Optimization level. See `qbs.optimization`.

### treatWarningsAsErrors

Type: | `bool`
Default: | `false`

Warnings will be handled as errors and cause the build to fail.

### warningLevel

Type: | `string`
Allowed Values: | `"none"`, `"all"`
Default: | `"all"`

Specifies the warning level for the compiler.

### commonCompilerFlags

Type: | `stringList`
Default: | undefined

Flags that are added to all compilation commands independently of the language.

### cppFlags

Type: | `stringList`
Default: | undefined

Additional flags for the C preprocessor.

### cFlags

Type: | `stringList`
Default: | undefined

Additional flags for the C compiler.

### cxxFlags

Type: | `stringList`
Default: | undefined

Additional flags for the C++ compiler.

### objcFlags

Type: | `stringList`
Default: | undefined

Additional flags for the Objective-C compiler.

### objcxxFlags

Type: | `stringList`
Default: | undefined

Additional flags for the Objective-C++ compiler.

### linkerFlags

Type: | `stringList`
Default: | undefined

Additional flags for the linker.

### compilerName

Type: | `string`
Default: | determined by qbs-detect-toolchains

Name of the compiler binary. This is set in the build profile.

### compilerPath

Type: | `string`
Default: | determined by qbs-detect-toolchains

Full path of the compiler binary. This is set in the build profile.

### compilerWrapper

Type: | `stringList`
Default: | `undefined`

Wrapper binary and its arguments for wrapping compiler calls. This is useful for compiler wrappers like ccache and alike.

### linkerName

Type: | `string`
Default: | determined by qbs-detect-toolchains

Name of the linker binary. This is set in the build profile.

### linkerPath

Type: | `string`
Default: | determined by qbs-detect-toolchains

Full path of the linker binary. This is set in the build profile.

### supportedStaticLibrarySuffixes

Type: | `stringList`
Default: | `undefined`

List of file suffixes this toolchain's linker accepts as input. For example, for MinGW this list should be `[".a", ".lib"]`.

## Properties Specific to iOS and OS X

### frameworkPaths

Type: | `pathList`
Default: | `undefined`

List of framework search paths. Relative paths are considered to be relative to the .qbs product file they are used in.

### systemFrameworkPaths

Type: | `pathList`
Default: | `undefined`

List of framework search paths. Relative paths are considered to be relative to the .qbs product file they are used in. Header files in frameworks in those paths will not cause warnings.

### frameworks

Type: | `stringList`
Default: | `undefined`

List of frameworks to be linked. If the framework is part of your project, consider using a Depends item instead.

### weakFrameworks

Type: | `stringList`
Default: | `undefined`

List of frameworks to be weakly linked. If the framework is part of your project, consider using a Depends item instead.

### infoPlistFile

Type: | `path`
Default: | `undefined`

Path to the Info.plist file used by the bundle. The contents of this file will be aggregated with the values in `infoPlist`. If `infoPlistFile` and `infoPlist` contain the same key, the latter will take precedence, but may also be overridden during postprocessing (see `processInfoPlist`). If undefined, will not be taken into account.

### infoPlist

Type: | `object`
Default: | `undefined`

Dictionary of key-value pairs to add to the bundle's Info.plist. The contents of this property will be aggregated with the values from `infoPlistFile`. If `infoPlist` and `infoPlistFile` contain the same key, the former will take precedence, but may also be overridden during postprocessing (see `processInfoPlist`). If undefined, will not be taken into account.

### processInfoPlist

Type: | `bool`
Default: | `true`

Whether to perform post-processing on the aggregated Info.plist contents. If this property is `true`, various post-processing operations will be applied to the bundle's property list dictionary after it has been aggregated from the contents of the file specified by the `infoPlistFile` property and the `infoPlist` property. First, values from a list of defaults will be added to the dictionary if they were not already present. Then, values from the AdditionalInfo key of the platform SDK's Info.plist file will be added to the dictionary if they were not already present, as well as some other miscellaneous keys, such as BuildMachineOSBuild and UIDeviceFamily (on iOS). Finally, variable expansions will be performed such that substrings of the form $(VAR) or ${VAR} will be replaced with their corresponding environment variables.

### infoPlistFormat

Type: | `string`
Allowed Values: | `"xml1"`, `"binary1"`, `"json"`, `"same-as-input"`
Default: | `"binary1"` for iOS; `"same-as-input"` or `"xml1"` for OS X depending on whether `infoPlistFile` is specified; undefined for all other operating systems.

The file format to write the product's resulting Info.plist in.

## Properties Specific to iOS

### minimumIosVersion

Type: | `string`
Default: | undefined, but may be set by generated profiles

A version number in the format [major].[minor] indicating the earliest version of OS X that the product should run on. Passes -miphoneos-version-min=<version> to the compiler. If undefined, compiler defaults will be used.

## Properties Specific to OS X

### minimumOsxVersion

Type: | `string`
Default: | undefined, but may be set by generated profiles

A version number in the format [major].[minor] indicating the earliest version of OS X that the product should run on. Passes -mmacosx-version-min=<version> to the compiler. If undefined, compiler defaults will be used.

## Properties Specific to Unix Platforms

### archiverName

Type: | `string`
Default: | `"ar"`

Name of the archiver binary. This is set in the build profile.

### archiverPath

Type: | `string`
Default: | determined by qbs-detect-toolchains

Full path of the archiver binary. This is set in the build profile.

### positionIndependentCode

Type: | `bool`
Default: | `undefined`

Generate position independent code. If this property is `undefined`, then position independent code is generated for libraries, but not for applications.

### rpaths

Type: | `stringList`
Default: | `undefined`

List of rpaths that are passed to the linker.

### visibility

Type: | `string`
Allowed Values: | `"default"`, `"hidden"`, `"hiddenInlines"`
Default: | `"default"`

Visibility level for exported symbols.

## Properties Specific to Windows

### windowsApiCharacterSet

Type: | `string`
Allowed Values: | `"unicode"`, `"mbcs"`, `undefined`
Default: | `"unicode"`

Specifies the character set used in the Win32 API. "unicode" will define the preprocessor symbols UNICODE and _UNICODE, "mbcs" will define _MBCS, and setting the value to undefined will use the default character set.

### minimumWindowsVersion

Type: | `string`
Default: | undefined, but may be set by generated profiles

A version number in the format [major].[minor] indicating the earliest version of Windows that the product should run on. Defines WINVER, _WIN32_WINNT, and _WIN32_WINDOWS, and applies a version number to the linker flags /SUBSYSTEM and /OSVERSION for MSVC or -Wl,--major-subsystem-version, -Wl,--minor-subsystem-version, -Wl,--major-os-version and -Wl,--minor-os-version for MinGW. If undefined, compiler defaults will be used.