- Qbs Manual
- Qbs 1.23.1

Project ◦ PropertyOptions

# Properties

Provides conditional setting of properties. More...

- List of all members, including inherited members

## Properties

- condition : bool
- overrideListProperties : bool

## Detailed Description

Note: This topic documents the Properties item in the context of products. For more information about using it in sub-projects, see SubProject.

The Properties item is an auxiliary item for setting multiple property values conditionally.

In the following example, two properties are set if the project is built for Windows:

     Product {
         Properties {
             condition: qbs.targetOS.contains("windows")
             cpp.defines: ["ON_WINDOWS"]
             cpp.includePaths: ["extraWindowsIncludes"]
         }
     }

Multiple Properties items can be specified to set properties dependent on different conditions. The order of appearance is important. Semantics are similar to if-else-chains. The following example

     Product {
         Properties {
             condition: qbs.targetOS.contains("windows")
             cpp.defines: ["ON_WINDOWS"]
             cpp.includePaths: ["myWindowsIncludes"]
         }
         Properties {
             condition: qbs.targetOS.contains("linux")
             cpp.defines: ["ON_LINUX"]
             cpp.includePaths: ["myLinuxIncludes"]
         }
         cpp.defines: ["ON_UNKNOWN_PLATFORM"]
     }

is equivalent to

     Product {
         cpp.defines: {
             if (qbs.targetOS.contains("windows"))
                 return ["ON_WINDOWS"];
             if (qbs.targetOS.contains("linux"))
                 return ["ON_LINUX"];
             return ["ON_UNKNOWN_PLATFORM"];
         }
         cpp.includePaths: {
             if (qbs.targetOS.contains("windows"))
                 return ["myWindowsIncludes"];
             if (qbs.targetOS.contains("linux"))
                 return ["myLinuxIncludes"];
             return base;
         }
     }

In Properties items, one can access the outer value of a property.

     Product {
         Properties {
             condition: qbs.targetOS.contains("windows")
             cpp.defines: outer.concat("ON_WINDOWS")     // === ["FOO", "ON_WINDOWS"]
         }
         Properties {
             condition: qbs.targetOS.contains("linux")
             cpp.defines: ["ON_LINUX"]                   // === ["ON_LINUX"]
         }
         cpp.defines: ["FOO"]
     }

We suggest to use the Properties item for mutually exclusive conditions only. It is especially useful if there are several properties to set, based on the same condition.

## Property Documentation

condition : bool

The condition to be used for the other bindings in this item.

This is a mandatory property that has no default value.

overrideListProperties : bool

List properties set within this item will override the values coming from modules, rather than getting merged with them, which is the default behavior. Use this in the rare case that a module you depend on inserts a value into a list property that is problematic for some product.

Default: `false`

Project ◦ PropertyOptions