Skip to content

build: add Meson build support and export a C++20 module interface - #240

Open
lozkoev wants to merge 4 commits into
minio:mainfrom
lozkoev:main
Open

build: add Meson build support and export a C++20 module interface#240
lozkoev wants to merge 4 commits into
minio:mainfrom
lozkoev:main

Conversation

@lozkoev

@lozkoev lozkoev commented Aug 2, 2026

Copy link
Copy Markdown

What

  • Adds a meson.build (and a Meson-native .wrap-friendly layout) so this
    library can be consumed directly by Meson-based projects, without going
    through CMake at all.
  • Adds modules/miniocpp.cc - a C++20 module interface (export module miniocpp;) that re-exports the public API (minio::s3::Client,
    BaseUrl, BucketExistsArgs/BucketExistsResponse, minio::creds:: StaticProvider, minio::Result), so consumers can import miniocpp;
    instead of #include <miniocpp/client.h>.
  • Attaches that module to the existing miniocpp CMake target via
    FILE_SET CXX_MODULES (CMake 3.28+), gated behind MINIO_CPP_STD=20 and
    the CMake version check, so CMake/MSBuild consumers get import miniocpp;
    too, not only Meson ones.
  • Fixes miniocpp.pc.in: the generated .pc had an empty Requires: field,
    so pkg-config consumers never picked up curlpp/OpenSSL/pugixml/zlib
    transitively and failed to link. Added the missing Requires:.

Why

Building this project with Meson previously required either wrapping it
in a manual dependency(method: 'pkg-config')/method: 'cmake' call with
hand-written link flags (fragile, breaks whenever a dependency version
changes), or going through cmake.subproject(), which currently drops
include paths that live outside the subproject's own directory tree - a
known Meson limitation (see mesonbuild/meson#12451, #6079, #12351) that
makes it unusable for a library with external (e.g. vcpkg) dependencies.
A real meson.build avoids both problems.

The module interface is a small addition on top since C++20 modules are
increasingly the expected way to consume a library that already supports
C++20 (MINIO_CPP_STD=20, added in #237).

Example usage

import std;
import miniocpp;

int main() {
  minio::s3::BaseUrl base_url("localhost:9000", false);
  minio::creds::StaticProvider provider("minioadmin", "minioadmin");
  minio::s3::Client client(base_url, &provider);

  minio::s3::BucketExistsArgs args;
  args.bucket = "my-bucket";

  minio::Result<minio::s3::BucketExistsResponse> resp = client.BucketExists(args);
  if (!resp) {
    std::cout << "error: " << resp.error() << std::endl;
    return 1;
  }
  std::cout << "exists: " << std::boolalpha << resp->exist << std::endl;
}
# consumer's meson.build
miniocpp_dep = subproject('minio-cpp').get_variable('miniocpp_dep')
executable('app', 'main.cpp', dependencies: [miniocpp_dep])

Testing

  • Built and ran against a local MinIO instance on Windows (MSVC 19.51,
    MINIO_CPP_STD=20):
    • via CMake directly (FILE_SET CXX_MODULES path)
    • via Meson (subproject('minio-cpp'), full source build, not the vcpkg
      binary package)
  • check-style.sh clean (clang-format --style=Google)
  • check-version.py passes (no version bump in this change)
  • RDMA path untouched (MINIO_CPP_ENABLE_RDMA still defaults OFF; module/
    Meson additions don't touch it)

Summary by CodeRabbit

  • New Features

    • Added support for consuming the library as a C++20 module.
    • Added Meson build support.
    • Exposed commonly used client, credentials, bucket, and result APIs through the module.
  • Build & Installation

    • Improved CMake installation of module files, public headers, and bundled headers.
    • Added Windows socket libraries to generated package metadata.
  • Bug Fixes

    • Updated pkg-config metadata to accurately report required dependencies and additional libraries.

@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The pull request adds a C++20 miniocpp module. CMake and Meson build the module. CMake conditionally installs the module and additional headers. Pkg-config metadata lists required libraries and extra linker flags.

Changes

C++20 module and build integration

Layer / File(s) Summary
C++20 module interface
modules/miniocpp.cc
The new module includes miniocpp/client.h and re-exports selected S3, credentials, and result APIs.
CMake module registration and installation
CMakeLists.txt
CMake registers and installs the module for C++20 configurations. It installs result.h and vendored tl headers. Windows package metadata includes socket libraries.
Meson targets and package metadata
meson.build, miniocpp.pc.in
Meson builds the main and module libraries and exposes their combined dependency. Pkg-config metadata lists required dependencies and extra linker flags.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant CMake
  participant miniocpp_target
  participant Install
  CMake->>miniocpp_target: Register modules/miniocpp.cc for C++20
  miniocpp_target->>Install: Install the CXX_MODULES file set
Loading

Possibly related PRs

Suggested reviewers: harshavardhana

Poem

A rabbit hops through C++ land,
A module builds by clear command.
CMake and Meson share the way,
Headers join the install array.
miniocpp grows neat and bright.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the two primary changes: Meson build support and a C++20 module interface.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@meson.build`:
- Line 1: Update the project configuration in meson.build to require C++20 for
the miniocpp module build, and make the cpp_args setting conditional so
/interface is supplied only when meson.get_compiler('cpp').get_id() is msvc; use
no MSVC-specific flag for GCC or native Clang builds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 229fd75c-ae3d-4238-a93b-13861489acae

📥 Commits

Reviewing files that changed from the base of the PR and between 313486d and 0bc22b5.

📒 Files selected for processing (4)
  • CMakeLists.txt
  • meson.build
  • miniocpp.pc.in
  • modules/miniocpp.cc

Comment thread meson.build

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
CMakeLists.txt (2)

322-337: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Export C++ module files with the target export.

When MINIO_CPP_HAS_CXX_MODULE is ON, the install(TARGETS miniocpp EXPORT miniocpp-targets ... FILE_SET CXX_MODULES ...) installs module files, but install(EXPORT miniocpp-targets ...) does not set CXX_MODULES_DIRECTORY. Add CXX_MODULES_DIRECTORY to the export installation for module-enabled builds; the project compatibility branch still supports CMake older than 3.28, so do not add it outside this branch.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CMakeLists.txt` around lines 322 - 337, Update the module-enabled CMake
installation branch for the miniocpp target so its corresponding install(EXPORT
miniocpp-targets ...) call sets CXX_MODULES_DIRECTORY. Keep this option
restricted to the MINIO_CPP_HAS_CXX_MODULE branch and leave the compatibility
branch unchanged for older CMake versions.

182-200: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Gate C++ module registration on supported toolchain and generator combinations.

target_sources(miniocpp ... FILE_SET CXX_MODULES ...) is registered when only CMAKE_VERSION >= 3.28 and MINIO_CPP_STD == "20" are true. File type registration and dependency scanning can then run for unsupported GCC/Clang versions or Makefile generators. Add checks for CMAKE_CXX_COMPILER_ID, minimum compiler version, and CMAKE_GENERATOR, or make this truly opt-in with a clear diagnostic when modules/miniocpp.cc cannot be supported.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@CMakeLists.txt` around lines 182 - 200, Update the MINIO_CPP_HAS_CXX_MODULE
guard around target_sources(miniocpp) so module registration occurs only for
supported C++20 compiler and generator combinations: validate
CMAKE_CXX_COMPILER_ID, the compiler’s minimum supported version, and
CMAKE_GENERATOR in addition to the existing CMake and standard checks. Keep the
module disabled otherwise and provide a clear diagnostic when
modules/miniocpp.cc is requested but unsupported.
meson.build (1)

46-57: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

Add non-MSVC module support or restrict the Meson target.

cpp_std=c++20 does not enable GCC module compilation, and the non-MSVC branch does not generate or export a BMI. Clang supports C++20 modules but still needs module artifact propagation for consumers. Add a Meson test that uses import miniocpp; with GCC and Clang. If these toolchains are supported, add their compiler-specific module flags and propagate the module artifact through miniocpp_dep; otherwise, disable this target for unsupported non-MSVC toolchains.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@meson.build` around lines 46 - 57, Update the miniocpp_module target and
miniocpp_dep to either implement compiler-specific C++20 module support for GCC
and Clang—including BMI generation, a Meson compile test using import miniocpp;,
and propagation of the module artifact—or restrict/disable the target for
unsupported non-MSVC compilers. Preserve the existing MSVC configuration and
ensure consumers of miniocpp_dep receive the required module metadata.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@CMakeLists.txt`:
- Around line 322-337: Update the module-enabled CMake installation branch for
the miniocpp target so its corresponding install(EXPORT miniocpp-targets ...)
call sets CXX_MODULES_DIRECTORY. Keep this option restricted to the
MINIO_CPP_HAS_CXX_MODULE branch and leave the compatibility branch unchanged for
older CMake versions.
- Around line 182-200: Update the MINIO_CPP_HAS_CXX_MODULE guard around
target_sources(miniocpp) so module registration occurs only for supported C++20
compiler and generator combinations: validate CMAKE_CXX_COMPILER_ID, the
compiler’s minimum supported version, and CMAKE_GENERATOR in addition to the
existing CMake and standard checks. Keep the module disabled otherwise and
provide a clear diagnostic when modules/miniocpp.cc is requested but
unsupported.

In `@meson.build`:
- Around line 46-57: Update the miniocpp_module target and miniocpp_dep to
either implement compiler-specific C++20 module support for GCC and
Clang—including BMI generation, a Meson compile test using import miniocpp;, and
propagation of the module artifact—or restrict/disable the target for
unsupported non-MSVC compilers. Preserve the existing MSVC configuration and
ensure consumers of miniocpp_dep receive the required module metadata.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3b9fbe6b-5d18-4bf2-ab3c-6de2919f705e

📥 Commits

Reviewing files that changed from the base of the PR and between 0bc22b5 and 10b36c8.

📒 Files selected for processing (3)
  • CMakeLists.txt
  • meson.build
  • miniocpp.pc.in

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant