How to pull a dependency with specific setting in a conanfile.py?

Viewed 347

I am creating a recipe for my project. The project has a dependency on a package, for example "pcapplusplus/18.08". Easy enough, I do this with:

class MyProject(ConanFile):
    name = "myproject"
    version = "0.1"
    settings = "os", "compiler", "build_type", "arch"

    # ...simplified...

    requires = "pcapplusplus/18.08"

    # ... configure, build etc

Except the pcapplusplus dependency has to be pulled with the setting compiler.version=15. Akin to this syntax in a profile:

[settings]
pcapplusplus:compiler.version=15

Or from conan install:

conan install . -s pcapplusplus:compiler.version=15

How is this done in a conanfile.py?

1 Answers

The [settings] you are describing is not a conanfile.txt. It is a profile file that must be used as:

$ conan install <path-to-conanfile> --profile=<path-to-profile>

The profile files can be used both for conanfile.txt and conanfile.py files.

Related