Conan: How do you reference packages specified in build_requires?

Created on 28 Jun 2018  路  3Comments  路  Source: conan-io/conan

Say you have a package that depends on another package. How do you reference that requirement in your build step? For example,

from conans import ConanFile

class PkgB(ConanFile):
   name="pkgB"
   exports="*"
   build_requires="pkgA/1.0@me/stable"

   def build(self):
      self.run("make pkBPath=<Need path to pkgB here>")

I'm probably just approaching this the wrong way. How is this supposed to be handled?

question

All 3 comments

Hi @rconde01,

You are looking for the deps_cpp_info attribute. This gathers all the information from dependencies like include folders, lib folders, flags and so on.

Its usage looks something like this:

from conans import ConanFile

class PkgB(ConanFile):
   name="pkgB"
   exports="*"
   requires="pkgA/1.0@me/stable"

   def build(self):
      self.run("make pkgAPath=%s" % self.deps_cpp_info["pkgA"].lib_paths[0])

*I think what you meant was actually "make pkgAPath=...", if not please explain

Hope that helps! Do not hesitate to ask any other doubt

Yes - you're right...I meant pkgA, not package B...i will look into that thanks...if it works out i will close. Thanks for the quick response! You may want to add that to an example in the documentation for build_requires.

this worked thanks

Was this page helpful?
0 / 5 - 0 ratings