QbsDeps

The QbsDeps generator produces the necessary files for each dependency to be able to use the qbs Depends item to locate the dependencies. It can be used like:

  1. from conan import ConanFile
  2. class App(ConanFile):
  3. settings = "os", "arch", "compiler", "build_type"
  4. requires = "hello/0.1"
  5. generators = "QbsDeps"

It is also possible to use QbsDeps manually in the generate() method:

  1. from conan import ConanFile
  2. from conan.tools.qbs import QbsDeps
  3. class App(ConanFile):
  4. settings = "os", "arch", "compiler", "build_type"
  5. requires = "hello/0.1"
  6. def generate(self):
  7. deps = QbsDeps(self)
  8. deps.generate()

The dependency to the application can be added using the Depends item:

project.qbs

  1. CppApplication {
  2. Depends { name: "hello"; version: "0.1" }
  3. files: "main.c"
  4. qbs.installPrefix: ""
  5. install: true
  6. qbsModuleProviders: "conan"
  7. moduleProviders.conan.installDirectory: "build"
  8. }

Note that we are setting the qbsModuleProviders property to "conan" in order to tell Qbs that dependencies are generated by Conan. We also set the installDirectory property of the conan module provider to "build" to tell the provider to look for generated files in the build directory within the source directory. It is also possible to set this value from command line.

We install dependencies using the conan install command.

  1. $ conan install . --output-folder=build --build missing

Finally, we can build the project by simply calling Qbs:

  1. $ qbs

Note, that Qbs helper will automatically set the conan.installDirectory property when QbsDeps generator is used.

See also

Reference

class QbsDeps(conanfile)

This class will generate a JSON file for each dependency inside the “conan-qbs-deps” folder. Each JSON file contains information necesary for Qbs "conan" module provider to be able to generate Qbs module files.

  • Parameters:

    conanfile – The current recipe object. Always use self.

  • property content

    Returns all dependency information as a Python dict object where key is the dependency name and value is a dict with dependency properties.

  • generate()

    This method will save the generated files to the “conan-qbs-deps” directory inside the conanfile.generators_folder directory. Generates a single JSON file per dependency or component.