- Qbs Manual
- Properties Item
- Qbs 1.6.0

Project Item PropertyOptions Item

# Properties Item

Note: This documents the `Properties` item in the context of products. Usage within a `SubProject` item is described here.

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

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 | Type | Default | Description
--- | --- | --- | ---
condition | bool | none - must be specified | The condition to be used for the other bindings in this item.

Project Item PropertyOptions Item