How to use different version of a Conan packaged library for different versions of the operating system or compiler?

  Kiến thức lập trình

I have the following conanfile.txt.

[requires]
boost/1.79.0
oatpp/1.3.0
sqlite3/3.39.4
oatpp-sqlite/1.3.0

On Ubuntu 24.04.1 LTS with g++ 13.2.0 the build gives me the following error:

[cmake] ERROR: Version conflict: Conflict between sqlite3/3.45.0 and sqlite3/3.39.4 in the graph.
[cmake] Conflict originates from oatpp-sqlite/1.3.0

I can bump the version in the conanfile.txt to 3.45.0 and then the build is fine. But then on another colleague’s machine with Ubuntu 22.04 the build process gives the same error, requiring him to get down the version of the library to 3.39.4 for the build to work.

Is it possible to select the library version according to the OS/compiler version in the conanfile.txt/py or in some system-wide override?

Sure, you can have conditional requirements:

def requirements(self):
    if self.settings.compiler == "gcc" and self.settings.compiler.version == "13":
        self.requires("sqlite3/3.45.0")
    else:
        self.requires("sqlite3/3.39.4")

Still, I am a bit surprised this is necessary, it is very unusual that there are conditional requirements in ConanCenter recipes to produce this kind of conflict. I have done a search in conan-center-index repository, and I cannot find any requirement to sqlite3/3.39. So it seems there are some outdated recipes there or maybe it is using packages not only from ConanCenter but also custom packages from a private repository. So maybe making sure to update to some other latest versions of other packages could help too.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website Kho Theme wordpress Kho Theme WP Theme WP

LEAVE A COMMENT