[CMake] protozero targets
Currently, the CMake files do not create a target for the protozero library itself.
CMake supports so called interface targets, which are targets which contain only header files but do not build anything.
So instead of making the includes available everywhere, an application that wants to use protozero can link against that target.
(The canonical way would be to call it protozero::protozero).
Would you accept a PR that makes the required changes?
It would then allow to use protozero as via add_subdirectory, or via find_package(protozero REQUIRED), but instead of manually providing a FindProtozero.cmake file, it would generate a protozere-config.cmake file upon install.
Protozero has been around since before CMake introduced that capability/syntax and is used by software using the "old" approach that we currently have. I'd be all for changing that but we need to do it in a backwards compatible way. If you know how to do that, I think we'd be willing to consider a PR.
@joto we have VERSION 3.10.0 in our CMake file already, primarily because CMake 4 errors when the version in a CMake file is too old, so I’m not sure that we necessarily need to worry about versions of CMake that don’t support this syntax. If you truly need to use an archaic version of CMake, you can always resort to just adding the protozero include directory to your target, since there’s no complex build step involved for Protozero anyway, and a CMake target would mostly be a convenience feature.
@kkaefer I am not worried about old CMake versions, I am worried about old users of protozero who use the old way of things in their CMake configs.
I think I can find a way to make it compatible, probably using some kind of option.
We can always define the targets, but opt out of include_directories.
Which CMake version would be ok as a minimum? 3.23 provides file sets, which makes it even easier to install the headers, but something older would also work.
Debian Bullseye is still supported and probably used by some and it has CMake 3.18.4., Ubuntu 22.04 has CMake 3.22.1. I think we don't need go farther back then these, but would be good to keep support for them.