sony / nmos-cpp

An NMOS (Networked Media Open Specifications) Registry and Node in C++ (IS-04, IS-05)
Apache License 2.0
136 stars 80 forks source link

Remove direct dependency on zlib? #385

Open garethsb opened 3 months ago

garethsb commented 3 months ago

https://github.com/sony/nmos-cpp/commit/d5a45b087f51026578d9b7a9af7a425f9f6d4d08 added a direct dependency on zlib in order to avoid version conflict between indirect dependencies on zlib via cpprestsdk and boost.

Now that we are using Conan 2, we have more facilities to avoid that sort of breakage. For starters, the recipes for Boost and cpprestsdk now specify a version range: https://github.com/conan-io/conan-center-index/blob/66ef25739f25d2a23c131bc4eb0fd0dfab8450b5/recipes/boost/all/conanfile.py#L650 https://github.com/conan-io/conan-center-index/blob/66ef25739f25d2a23c131bc4eb0fd0dfab8450b5/recipes/cpprestsdk/all/conanfile.py#L63

Secondly, Conan now provides a way of clearly specifying an override for dependencies which still isn't a direct dependency: https://docs.conan.io/2/tutorial/versioning/conflicts.html

However, as far as I know, that feature is not available as a conan install command line argument, nor available within a conanfile.txt. I don't think lockfiles are the answer, because this conflict can happen while computing the dependency graph the first time.

So I think the correct solution is to use a conanfile.py with an override=True requirement, instead of a conanfile.txt.

Note that in the CCI recipe, I am actually removing the zlib dependency completely, because the best practice is that override=True is specified by the ultimate consumer recipe: https://github.com/conan-io/conan-center-index/pull/23411

If we keep the conanfile.txt, we should still remove the [imports] section, since this is ignored in Conan 2, you need to use generators: https://docs.conan.io/1/migrating_to_2.0/recipes.html#removed-imports-method

The CCI recipe already has a fully-fledged generate method: https://github.com/conan-io/conan-center-index/blob/66ef25739f25d2a23c131bc4eb0fd0dfab8450b5/recipes/nmos-cpp/all/conanfile.py#L90