1

Learning Conan right now, I am trying to rewrite part of my CMake files to use conan instead of other package managers like CPM and the CMake built-in FetchContent_Declare function. Among other packages, I am using the followings with corresponding versions:

fmt: 9.1.0

spdlog: 1.11.0

I can fetch them both and build & run my code using CPM but FetchContent_Declare but using conan, I get the following version conflict error which I don't understand why it happens:

ERROR: Version conflict: spdlog/1.11.0->fmt/10.0.0, ->fmt/9.1.0.

My conanfile.py looks like below:

from conan import ConanFile
from conan.tools.cmake import CMakeToolchain

class CompressorReceipe(ConanFile):
    settings = "os", "compiler", "build_type", "arch"
    generators = "CMakeDeps"

    def requirements(self):
        self.requires("nlohmann_json/3.11.2")
        self.requires("spdlog/1.11.0")
        self.requires("fmt/9.1.0")
        self.requires("catch2/2.13.9")
        self.requires("cxxopts/3.1.1")

    def generate(self):
        tc = CMakeToolchain(self)
        tc.user_presets_path = False
        tc.generate()

and looking into the spdlog dependeny info on the conan center I can only see that it depends on fmt/9.1.0 and not 10.0.0 as it complains about in the error:

spdlog screenshot from conan center

For testing purpose, I upgraded my fmt to 10.0.0 and it can compile but still, I don't understand why this error is happening while there shall be no version conflict according to the spdlog info on the conan center.

My environemnt is Linux via WSL and the compiler is gcc.

Ramin Toussi
  • 97
  • 1
  • 11
  • 1
    The spdlog project is very explicit about which fmt version should be used. For instance, 1.11.0 requires fmt/9.1.0 (see https://github.com/gabime/spdlog/releases/tag/v1.11). For Conan, when you include same package twice, but with different versions, is a conflict, and the user should fix. There are several ways to fix it (see https://docs.conan.io/2/tutorial/versioning/conflicts.html#resolving-conflicts) but for your specific case, better keeping fmt/9.1.0 version only, as spdlog will not work with fmt 10.x. You can use version range to avoid problems, like `fmt/[<=10.0.0]`. – uilianries Jun 29 '23 at 15:01
  • 1
    @uilianries Thanks for the comment, it was so insightful on how to resolve the conflicts. Your comment can be selected as an answer if you put it down there – Ramin Toussi Jun 30 '23 at 09:19
  • Glad it fits your case. Not needed as Answer, helping is more than enough for me. Regards. – uilianries Jun 30 '23 at 13:23

0 Answers0