- Qbs Manual
- QbsLanguageItems
- Group
- Qbs 3.3.1

FileTagger ◦ JobLimit

# Group

Groups files and other items in a product or module. More...

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

## Properties

- condition : bool
- excludeFiles : pathList
- fileTags : stringList
- fileTagsFilter : stringList
- files : pathList
- filesAreTargets : bool
- name : string
- overrideTags : bool
- prefix : string

## Detailed Description

This item is attached to a product or module and used to group files and other items that have something in common.

## Typical Uses of Groups by Example

     Application {
         Group {
             name: "common files"
             files: ["myclass.h", "myclass_common_impl.cpp"]
         }
         Group {
             name: "Windows files"
             condition: qbs.targetOS.includes("windows")
             files: "myclass_win_impl.cpp"
         }
         Group {
             name: "Unix files"
             condition: qbs.targetOS.includes("unix")
             files: "unixhelper.cpp"
             Group {
                 name: "Linux files"
                 condition: qbs.targetOS.includes("linux")
                 files: "myclass_linux_impl.cpp"
             }
             Group {
                 name: "FreeBSD files"
                 condition: qbs.targetOS.includes("freebsd")
                 files: "myclass_freebsd_impl.cpp"
             }
         }
         Group {
             name: "Files to install"
             qbs.install: true
             qbs.installDir: "share"
             files: "runtime_resource.txt"
         }
     }

## Wildcards

When specifying files, you can use the wildcards `"*"`, `"?"` and `"[]"`, which have their usual meaning as in Unix Shell. By default, matching files are only picked up directly from the parent directory, but you can tell Qbs to consider the whole directory tree. It is also possible to exclude certain files from the list. The pattern `"**"` used in a pathname expansion context will match all files and zero or more directories and subdirectories. For example:

             Group {
                 name: "Word processing documents"
                 files: ["*.doc", "*.rtf"]
                 prefix: "**/"
                 qbs.install: true
                 qbs.installDir: "share"
                 excludeFiles: "do_not_install_this_file.*"
             }

## Attaching Module Properties to Source Files

Within a `Group` item, module properties can be attached either to all files in the product, or to only the files in that group. The following example demonstrates both:

     Product {
         // ...
         Group {
             condition: project.hasSpecialFeature
             cpp.defines: "FEATURE_SPECIFIC"
             product.cpp.defines: "WITH_FEATURE"
             files: "feature.cpp"
         }
     }

Here, the macro `"FEATURE_SPECIFIC"` will only be visible inside `feature.cpp`, whereas `"WITH_FEATURE"` applies to all source files in the product.

A group-level property binding starting with `"product."` is semantically equivalent to putting the same property binding without that prefix inside a top-level Properties item with the same condition as the group. The above example could therefore also have been written like this:

     Product {
         // ...
         Group {
             condition: project.hasSpecialFeature
             cpp.defines: "FEATURE_SPECIFIC"
             files: "feature.cpp"
         }
         Properties {
             condition: project.hasSpecialFeature
             cpp.defines: "WITH_FEATURE"
         }
     }

Obviously, the original variant is to be preferred, as it does not duplicate the condition and keeps related code close together.

It should be noted that there is a third way to write the same example, with a Properties item inside the group:

     Product {
         // ...
         Group {
             condition: project.hasSpecialFeature
             cpp.defines: "FEATURE_SPECIFIC"
             files: "feature.cpp"
             Properties {
                 cpp.defines: "WITH_FEATURE"
             }
         }
     }

This construct just adds verbosity here, but might be useful in cases where the product-level property binding is dependent on an additional condition.

## Attaching Module Properties to Generated Files

A group can also be used to attach properties to build artifacts such as executables or libraries. In the following example, an application is installed to "<install root>/bin".

     Application {
         Group {
             fileTagsFilter: "application"
             qbs.install: true
             qbs.installDir: "bin"
         }
     }

## Groups in Modules

Groups may also appear in modules, which causes the respective sources to be added to the products depending on the said module, unless the filesAreTargets property is set.

## Grouping Related Items

Groups can contain other items, namely Depends, FileTagger, Rule and Scanner items. They can also contain other groups, that is, they can be nested. The condition of a groups's child item gets logically ANDed with the one of the parent group. Additionally, if the child item is a group itself, the child group inherits the module properties and file tags as well as the prefix of its parent group.

## Property Documentation

condition : bool

Determines whether the files in the group are actually considered part of the project.

Default: `true`

excludeFiles : pathList

A list of files that are subtracted from the files list.

The values can contain wildcards.

This property is ignored if fileTagsFilter is set.

Default: An empty list

fileTags : stringList

A list of file tags to attach to the group's files. These can then be matched by a rule.

Note: File taggers are never applied to a file that has this property set.

Default: An empty list

fileTagsFilter : stringList

List of artifact.fileTags to match. Any properties set in this group will be applied to the product's artifacts whose file tags match the ones listed here.

The file tags that the group's fileTags property specifies will be added to the matching artifacts.

This property is mutually exclusive with files.

Default: An empty list

files : pathList

The files in the group. Mutually exclusive with fileTagsFilter. Relative paths are resolved using the parent directory of the file that contains the Group item. However, if the prefix property is set to an absolute path, then that one becomes the base directory.

The values can contain wildcards.

Default: An empty list

filesAreTargets : bool

If this property is `true` and the group is in a Module, the files in the group will not become source artifacts of the product that depends on the module. Instead, they are treated like target artifacts of products. That is, they will be matched against the inputsFromDependencies file tag list of rules in products that depend on the module.

Default: `false`

name : string

The name of the group. Not used internally; mainly useful for IDEs.

Default: "Group x", where x is a unique number among all the groups in the product.

overrideTags : bool

Determines how tags on files that are listed both at the top level of a product (or the parent group, if there is one) and a group are handled. If this property is `true`, then the file tags set via the group replace the ones set via the product or parent group. If it is `false`, the group tags are added to the parent tags.

This property is ignored if fileTagsFilter is set.

Default: `true`

prefix : string

A string to prepend to all files. Slashes are allowed and have directory semantics.

Default: The prefix of the parent group if one exists, otherwise empty.