- Qbs Manual
- QbsLanguageItems
- Properties
- Qbs 3.2.0

Project ◦ PropertyOptions

# Properties

Provides conditional setting of properties. More...

- List of all members, including inherited members
- Properties is part of List of All Items.

## 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.includes("windows")
             cpp.defines: ["ON_WINDOWS"]
             cpp.includePaths: ["extraWindowsIncludes"]
         }
     }

As the above example demonstrates, the `Properties` item is especially useful if there are several properties whose values depend on the same set of conditions. These conditions do not need to be mutually exclusive, but care should be taken not to set the same scalar property in more than one matching `Properties` item. Qbs makes no guarantees about the value of the property in such cases.

If the same property is set both inside and outside of a `Properties` item, the behavior depends on the type of property:

- For scalar values, the outside binding is only considered if none of the `Properties` conditions match, that is, it acts as an "else" case.
- For list values, the outside value is always considered.

     Product {
         Properties {
             condition: qbs.targetOS.includes("windows")
             cpp.defines: ["ON_WINDOWS"]
             cpp.includePaths: ["myWindowsIncludes"]
             cpp.treatWarningsAsErrors: false
         }
         Properties {
             condition: qbs.targetOS.includes("linux")
             cpp.defines: ["ON_LINUX"]
             cpp.includePaths: ["myLinuxIncludes"]
         }
         cpp.defines: ["ALL_PLATFORMS"]
         cpp.treatWarningsAsErrors: true
     }

is roughly equivalent to

     Product {
         cpp.defines: {
             var defines = ["ALL_PLATFORMS"];
             if (qbs.targetOS.includes("windows"))
                 defines.push("ON_WINDOWS");
             if (qbs.targetOS.includes("linux"))
                 defines.push("ON_LINUX");
             return defines;
         }
         cpp.includePaths: {
             if (qbs.targetOS.includes("windows"))
                 return ["myWindowsIncludes"];
             if (qbs.targetOS.includes("linux"))
                 return ["myLinuxIncludes"];
             return base ? base : original;
         }
         cpp.treatWarningsAsErrors: !qbs.targetOS.includes("windows")
     }

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

     Product {
         property string theFeature: "basic"
         Properties {
             condition: qbs.targetOS.includes("windows")
             theFeature: outer + "_plus_windows" // === "basic_plus_windows"
         }
         Properties {
             condition: qbs.targetOS.includes("linux")
             theFeature: outer + "_plus_linux"   // === "basic_plus_linux"
         }
         cpp.defines: 'THE_FEATURE="' + theFeature + '"'
     }

## Property Documentation

### condition : bool `[default: true]`

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

Note: The special value `undefined` can be used to indicate that this condition should be considered true if and only if none of the other Properties items matched for a given property binding.

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