Search code examples
ubuntucmakemakefileconan

Using conan to package runtime dependencies


I'm using conan to build a handful of executable. Each executable requires a different set of libraries.

I'm building an installer and would like to find the runtime dependencies for each executable, copy them out of the .conan folder and into the staging area.

Is there a way to do that with conan?

For example, one of my executables requires libQt5Xml, which is distributed as an shared object (.so). The library is stored ~/.conan/data/qt/5.15.6///package/7b11ed4c9c45d7c7dde6e1a702e4fe4d3c4901c6/lib/libQt5Xml.so

It would be nice if I could:

  1. Somehow automatically generate the list of required libraries (name and version number)
  2. Somehow generate a list of paths to the files I need.

I guess I can parse the conanfile and use globs but I'm wandering if there is a better way?


Solution

  • There are a couple of different ways to collect information and copy files from dependencies:

    • You can use the generate() method of a consumer conanfile.py, and iterate via self.dependencies all the information, accessing the dep.package_folder, or dep.cpp_info.bindir, for example and do a copy()
    • You can use a deployer, at the moment there are a couple of built-in deployers, but custom ones can be created too, for example check the custom runtime deployer here. Deployers can be applied to any conan install, so no need to repeat the same generate() in all recipes that you want to use it.