镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Provide CMake components for different serialization formats #576

Open

Description

@deckstose

CMake supports finding specific package components, this is most prominently known with Qt, where you can call find_package(Qt6 REQUIRED COMPONENTS Widgets) to use widgets, but not the networking code for example.

The wish comes from the fact that I've recently evaluated to use this library and in the process came across the Debian package, which is compiled against all serialization formats. However, even if you just want to use json and toml, find_package will fail to find a good bson version. This is definitely a Debian packaging problem, however the library should provide a way to be packaged with all formats and only compile against the required parts when a user will only use a subset.

Copy-Paste Reproducer

Here a quick copy paste guide to reproduce:

podman run --rm -it --pull always debian:unstable
apt update && apt upgrade -y && apt install -y --no-install-recommends build-essential cmake ninja-build && apt install -y libreflectcpp-dev libtomlplusplus-dev libbson-dev
# CMakeLists.txt
cmake_minimu_required(VERSION 3.30)
project(foo CXX)
find_package(reflectcpp REQUIRED)
add_executable(foo foo.cc)
// foo.cc
auto main() -> int { return 0; }
cmake -B build -G Ninja

Activity

  1. liuzicheng1987 commented on Jan 18, 2026

    @liuzicheng1987
    Collaborator

    @deckstose, I have to admit, I am not entirely sure what you want is to do here.

    The library itself absolutely provides that. If you only compile the JSON and TOML features than only those dependencies are installed and required.

    I wasn't involved in making the Debian package, and frankly, didn't even know that one existed, so I can't really say much about that.

  2. deckstose commented on Jan 18, 2026

    @deckstose
    ContributorAuthor

    I have to admit, I am not entirely sure what you want is to do here.

    I suggest to make consuming the library more modular.

    The library itself absolutely provides that. If you only compile the JSON and TOML features than only those dependencies are installed and required.

    You're right, but this is only applicable if you control the build process.

    What solves this problem is if we could provide libreflectcpp.so + libreflectcpp-toml.so etc + CMakeConfig modules for each optional component. This way we could use an optional component, even if the library was build with all features enabled.

  3. liuzicheng1987 commented on Jan 19, 2026

    @liuzicheng1987
    Collaborator

    @deckstose, OK, I think that could be done.

  4. deckstose commented on Jan 22, 2026

    @deckstose
    ContributorAuthor

    @GregTheMadMonk

    This might be better discussed here. I was just throwing it in the module mix but I have no idea if modules are even designed for that.

    I have a branch here with exactly the ideas you have mentioned in #578 (comment). I not done with the design of the config.cmake file and installing headers in not ready either.

  5. deckstose commented on Jan 22, 2026

    @deckstose
    ContributorAuthor

    For me this seems to require listing all headers explicitly in target_sources ...

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