Skip to content

Provide CMake components for different serialization formats #576

@deckstose

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

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