Skip to content

[CMake] protozero targets #136

Open
Open

Description

@KerstinKeller

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.

Activity

  1. joto commented on Oct 10, 2025

    @joto
    Collaborator

    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.

  2. kkaefer commented on Oct 16, 2025

    @kkaefer
    Member

    @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.

  3. joto commented on Oct 16, 2025

    @joto
    Collaborator

    @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.

  4. KerstinKeller commented on Oct 17, 2025

    @KerstinKeller
    Author

    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.

  5. joto commented on Oct 17, 2025

    @joto
    Collaborator

    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.

  6. joto commented on Oct 15, 2026

    @joto
    Collaborator

    Taking a look at this again:

    1. Debian Bullseye is EOL, the oldest thing we would want to support is now Ubuntu 22.04 which has CMake 3.22.1
    2. There really is nothing in Protozero that needs fancy configuration, all we need really is the path to the include file, so the question is whether we need all of this at all. What the current script provides beyond that is just the version check.
    3. We probably can just have two versions of this script side by side. We can keep the old one for users of the "old way of doing things" and provide a new one for the rest. The script has to be copied into the project using it anyway. I should have thought about this earlier, sorry. So if anybody wants to provide a PR for the more modern CMake, please to so, keeping the old stuff in place.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions