- Qbs Manual
- Qbs 2.1.1

# ConanfileProbe

Extracts information about dependencies from a Conan recipe file. More...

- List of all members, including inherited members

## Properties

- additionalArguments : stringList
- conanfilePath : path
- dependencies : var
- executable : path
- generatedFilesPath : path
- generators : stringList
- json : var
- options : var
- packageReference : string
- settings : var
- verbose : var

## Detailed Description

The `ConanfileProbe` interfaces Qbs to the Conan package manager. It runs conan install on a Conan recipe file such as `conanfile.py` or `conanfile.txt` and extracts all available meta information about package dependencies using the json generator. The output may be used to set up Profile items or module properties in products. `ConanfileProbe` can also be used to run other Conan generators and to retrieve their output.

## Examples

In the following examples we assume that our project contains a `conanfile.py`. This file describes all dependencies of our project. The dependency packages are expected to export meta information to be consumed by our project.

### Including Files Generated by Conan

Conan has a built-in qbs generator that creates a project file containing dummy products. This is the easiest way to access dependencies, but also the least flexible one. It requires each Conan package to export correct meta information and works only if the dependency is a library.

     import qbs.Probes

     Project {
         Probes.ConanfileProbe {
             id: conan
             conanfilePath: project.sourceDirectory + "/conanfile.py"
             generators: "qbs"
         }

         references: conan.generatedFilesPath + "/conanbuildinfo.qbs"

         CppApplication {
             type: "application"
             files: "main.cpp"
             Depends { name: "mylib" }
         }
     }

### Setting Module Properties in Products

When a product depends on a Conan package that does not have a dedicated module, package meta information may be directly fed into the cpp module.

This approach is very flexible.

     import qbs.Probes

     CppApplication {
         Probes.ConanfileProbe {
             id: conan
             conanfilePath: product.sourceDirectory + "/conanfile.py"
             options: ({opt1: "True"; opt2: "TheValue"})
         }
         cpp.includePaths: conan.dependencies["myLib"].include_paths
         cpp.libraryPaths: conan.dependencies["myLib"].lib_paths
         cpp.dynamicLibraries: conan.dependencies["mylib"].libs
     }

### Setting Up a Profile

When multiple products depend on one or more Conan packages, the dependency information may be combined in a Profile. This is especially useful when Qbs modules are available for some of the packages, but some of their properties need to be initialized. Otherwise, it would have to be done manually in global profiles.

     import qbs.Probes

     Project {
         Probes.ConanfileProbe {
             id: conan
             conanfilePath: project.sourceDirectory + "/conanfile.py"
         }
         Profile {
             name: "arm-gcc"
             cpp.toolchainInstallPath: conan.dependencies["arm-none-eabi-gcc"].rootpath + "/bin"
             cpp.toolchainPrefix: "arm-linux-gnueabi-"
             qbs.toolchainType: "gcc"
         }
     }

This allows fully automated dependency management, including compiler toolchains and is very useful when teams work in heterougeneous environments.

## Property Documentation

additionalArguments : stringList

Additional command line arguments that are appended to the `conan install` command.

Default: []

conanfilePath : path

Path to a `conanfile.py` or `conanfile.txt` that is used by this probe.

This property cannot be set at the same time as packageReference.

Default: Undefined

[read-only] dependencies : var

This property contains the same information as json.dependencies, but instead of an array, `dependencies` is a map with package names as keys for convenient access.

Default: Undefined

executable : path

The name of or the path to the Conan executable.

Default: "conan.exe" on Windows, "conan" otherwise

[read-only] generatedFilesPath : path

The path of the folder where Conan generators store their files. Each instance of this probe creates a unique folder under Project.buildDirectory. The folder name is a hash of the arguments supplied to `conan install`.

Default: Undefined

generators : stringList

Conan generators to be executed by this probe. The JSON generator is always enabled. Generated files are written to the generatedFilesPath folder.

Default: ["json"]

See also Available generators.

[read-only] json : var

The parsed output of Conan's JSON generator as a JavaScript object.

Default: Undefined

options : var

Options applied to `conan install` via the `-o` flag. This property is an object in the form `key:value`.

Example:

     options: ({someOpt: "True", someOtherOpt: "TheValue"})

Default: Undefined

packageReference : string

Reference of a Conan package in the form `name/version@user/channel`. Use this property if you want to probe an existing package in the local cache or on a remote.

This property cannot be set at the same time as conanfilePath.

Default: Undefined

settings : var

Settings applied to `conan install` via the `-s` flag. This property is an object in the form `key:value`.

Example:

     settings: ({os: "Linux", compiler: "gcc"})

Default: Undefined

verbose : var

Set to `true` to print all output of `conan install`. If this property is `false` only error output will be printed.

Default: `false`