On Mon, 26 Dec 2022 at 14:00:31 +0100, Andrea Pappacoda wrote: > or patch zstd's makefiles to install a small Find > module itself (this is not really a good practice, as ideally upstreams > should install CMake Config files, but should work nonetheless).
If you're considering patching zstd's makefiles, I believe the preferred route is to install CMake "config modules" containing an imported target, like dbus and libsdl2 do. The one in dbus is a reasonably simple example of wrapping a pkg-config module with a CMake config module, while the one in libsdl2 bypasses pkg-config and provides the equivalent information more directly. Either way, this is something that would make sense to contribute upstream. Both dbus and libsdl2 have optional-but-not-recommended CMake build systems, similar to zstd, which we don't use in Debian; we follow upstream recommendations to build dbus with Autotools (in older branches) or Meson (in the 1.15.x development branch), and libsdl2 with Autotools. The Autotools and Meson build systems for those projects also install a simplified CMake config module, which can be consumed by CMake projects in the same way as if dbus/libsdl2 had themselves been built with CMake. The CMake config module is generated from a template using @variable@ substitutions. In older versions of libsdl2 the config module is not completely compatible with what its CMake build system would have installed, but the one in bookworm should be reasonably feature-complete. If dependent projects are expected to call find_package(Foo), then the CMake config module should be installed as either ${libdir}/cmake/Foo/FooConfig{,Version}.cmake in mixed-case (like dbus does) or ${libdir}/cmake/Foo/foo-config{,-version}.cmake in lower-case (like libsdl2 does). I don't know whether one of those is preferred over the other. It is a good idea to have a test for each supported use-case in the package's autopkgtests. dbus and libsdl2 have some tests for this which might make useful inspiration. smcv