Qbs Manual

Qbs 1.16.0

Depends ◦ FileTagger

# Export

Exports dependencies and properties to other products. More...

- List of all members, including inherited members

## Properties

- prefixMapping : var

## Detailed Description

An Export item can appear inside a Product item. It defines a Module with the product's name that can be depended on by other products. The properties attached to the Export item will take effect in all products that depend on the product inside which the Export item is defined. As an example, consider these two products:

      Product {
          name: "A"
          Export {
              Depends { name: "cpp" }
              cpp.includePaths: product.sourceDirectory
              cpp.defines: ["USING_" + product.name.toUpperCase()]
          }
      }

      Product {
          name: "B"
          Depends { name: "A" }
      }

The sources in product B will be able to use headers from product A without specifying the full path to them, because the include path has been made known to the compiler via A's Export item. Additionally, product B will be compiled with the define `USING_A`.

The dependent Product's modules are not exported unless explicitly specified within the Export item:

      Product {
          name: "B-Exporting-A"
          Depends { name: "A" }
          Export {
              Depends { name: "A" }
          }
      }

The relationship of the exported dependencies is transitive. A product C depending on a product B-Exporting-A will also get a direct dependency on A and thus inherit include paths and preprocessor macros exported by A.

      Product {
          name: "C"
          Depends { name: "B-Exporting-A" }
      }

In contrast to Module items, `product` within Export items refers to the product which defines the Export item. Use the `importingProduct` variable to refer to the product that pulls in the resulting module:

      Product {
          name: "D"
          Export {
              Depends { name: "cpp" }
              cpp.includePaths: [product.sourceDirectory, importingProduct.buildDirectory]
          }
      }

## Property Documentation

prefixMapping : var

This property allows to provide a translation of exported values between non-deployed and deployed contexts. It is an array of objects with properties `prefix` and `replacement`. The array's elements get applied to all other properties set in this item such that if the property's value start with `prefix`, that prefix gets replaced with `replacement`. It is typically used for C/C++ include paths. For instance, in a library that provides header files for inclusion both directly from its source directory (when building it as part of a bigger project) and from some installed location (when building an unrelated project against it), you would write something like the following:

      Export {
          Depends { name: cpp" }
          cpp.includePaths: [product.sourceDirectory]
          prefixMapping: [{
                  prefix: product.sourceDirectory,
                  replacement: FileInfo.joinPaths(qbs.installPrefix, "include")
          }]
      }

Default: `undefined`

This property was introduced in Qt 1.12.

See also Exporter.qbs and Exporter.pkgconfig.

Depends ◦ FileTagger