0

I have create a conan package for my libraries and noticed that I need to duplicate requires list for the library and for the package recipe. I wonder if there is a better way of doing it.

I am building conan packages for exising libraries. Say I have libA and libB - which depends on libA. That is in order to build libB I need libA built and 'installed'. So I have crafter conan package for libA which is build and installed as it has no other dependenices. I now can build libB with conan by specifiing in conanfile.txt that libB depends on libA. But when I am developing a package for libB I have to duplicate a list of dependencies of libB in requires property in conanfile.py.

cat libB/conanfile.txt
[requires]
libA/1@user/stable
...

cat conan-libsB/conanfile.py 
...
class LibBConan(ConanFile):
...
requires = "libA/1@user/stable"
...
def build(self):
    cmake = CMake(self, parallel=True)
    cmake.configure(source_folder=self.name)
    cmake.build()
    cmake.test()
    cmake.install()

The above is a simplified version from the real library https://github.com/abbyssoul/conan-libstyxe/blob/master/conanfile.py and https://github.com/abbyssoul/libstyxe/blob/master/conanfile.txt

Is it possible for conan to figure out that if the source package contains conanfile.[txt|py] then this defines requires field.

In case that a tool is required fist to source a package build_requires should be used.

AbbysSoul
  • 393
  • 1
  • 7
  • Hi! I would put the `conanfile.py` directly in the library repository and build the package from there, why do you want to have two different repositories? – jgsogo Jan 09 '19 at 16:39
  • 1
    The sources of a package are only retrieved when it is necessary to build from sources. But the conanfile.py of a package needs to know its dependencies, even if the sources are not retrieved at all. I would use just a ``conanfile.py`` in the repo, and that can be used both to consume and run ``conan install .`` in the local development, or to create a package with ``conan create``. – drodri Jan 09 '19 at 22:48

0 Answers0