Conan library with both static and dynamic libraries

Viewed 677

I have a project which uses libusb as a conan dependency. For most compilations (Windows and Linux), only using the static library was enough, but for cross-compiling this project from Linux to OSX it requires both the .dylib and .a files. When I run conan install with the dependencies, if I set the shared attribute to true, it attaches --enable-shared --disable-static to the configure process and if I set it to false, it sets --disable-shared --enable-static.

Is there any way in Conan I can directly influence the configure command (I already tried it out and that ensures that both files are created during the compilation of the library).

1 Answers

I originally developed that Conan package, and since then the community improved it a lot.

The short answer is No. Why? Conan packages were developed to separate shared libraries from static libraries for all projects. Each package has a specific package ID and they are not mixed in terms of libraries. This is a package design, not a Conan sanity rule.

If your project uses both libraries, I would say something is really wrong and should be fixed instead of looking for package workaround which could cost more time than fixing your real problem.

But if you don't find a solution, there is a hack, you can use Deploy generator, download both libraries to folder and configure your project consume from that folder.

Influence Conan to use the same package reference, but different options is not allowed by it design. Another option would be forking the original project and removing those options, and adding a new option "both", where both are present. Keep in mind "both" won't be accepted as official option.

Related