Skip to content

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

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

build: add Meson build support and export a C++20 module interface#240
lozkoev wants to merge 3 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 with compatible CMake configurations.
    • Added Meson build support for compiling and linking the library.
    • Exposed commonly used client, credentials, bucket, and result APIs through the C++20 module.
  • Bug Fixes

    • Updated pkg-config metadata to accurately report required cryptography, networking, XML, and compression libraries.
  • Build & Installation

    • Improved installation handling for C++20 module files while preserving existing behavior for older configurations.

@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 now build it. CMake installs the module conditionally. Pkg-config metadata now lists required libraries.

Changes

C++20 module and build integration

Layer / File(s) Summary
CMake module registration and installation
modules/miniocpp.cc, CMakeLists.txt
The new module re-exports selected public APIs. CMake registers and installs it when C++20 module support is enabled.
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 the required libraries.

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 blooms by build command.
CMake packs it, Meson sings,
Dependencies spread their wings.
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 summarizes the two main 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
@@ -0,0 +1,56 @@
project('miniocpp', 'cpp', version : '0.4.0')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Check that the module target requires C++20 and scopes MSVC-only flags.
rg -n -C 3 "project\\(|cpp_std|miniocpp_module|cpp_args|/interface|cxx\\.get_id" meson.build

# Expected:
# - C++20 is selected for the module build.
# - `/interface` appears only in an MSVC compiler-ID condition.

Repository: minio/minio-cpp

Length of output: 757


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== meson.build =="
cat -n meson.build

echo
echo "== module source excerpt =="
if [ -f modules/miniocpp.cc ]; then
  sed -n '1,120p' modules/miniocpp.cc
fi

echo
echo "== Meson compatibility docs in repo =="
fd -a 'meson|README|BUILD' . | sed 's#^\./##' | head -20

Repository: minio/minio-cpp

Length of output: 3054


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== README build sections =="
sed -n '1,240p' README.md | rg -n -C 4 -i "meson|build|install|module|cpp standard|c++20|clang|gcc|msvc|visual studio|interface" || true

echo
echo "== docs README =="
if [ -f docs/README.md ]; then sed -n '1,240p' docs/README.md; fi

Repository: minio/minio-cpp

Length of output: 6766


🌐 Web query:

Meson cpp_std c++20 project cpp

💡 Result:

To specify the C++20 standard in a Meson project, you should set the cpp_std option within the project() function call in your meson.build file [1][2]. The standard approach is to use the default_options argument [2]: project('my_project', 'cpp', default_options: ['cpp_std=c++20']) Advanced Configuration with Fallbacks Since Meson 1.3.0, cpp_std supports a list of values to handle cross-compiler compatibility [3]. If you want to use C++20 but allow fallbacks if the compiler does not support it, you can provide a prioritized list [4][3]: project('my_project', 'cpp', default_options: ['cpp_std=c++20,c++17']) Meson will select the first standard in the list that the current compiler supports [4][5][3]. Alternative Methods Per-Target Override: You can override the C++ standard for a specific target by using override_options [2]: executable('my_target', 'main.cpp', override_options: ['cpp_std=c++20']) Command Line: You can also change the standard during the configuration phase using the command line [6]: meson setup builddir -Dcpp_std=c++20 Note that while c++20 is the standard ISO designation, some compiler-specific values (like vc++20 for MSVC or gnu++20 for GNU-extended C++20) are available if specific compiler features or extensions are required [1][7]. However, c++20 is the recommended portable choice for modern projects [3].

Citations:


Set C++20 and limit /interface to MSVC.

modules/miniocpp.cc uses a C++20 named module, but meson.build does not select cpp20. Line 49 also passes the MSVC-only /interface option for every compiler, so GCC/native Clang Meson builds fail with an invalid compiler flag. Add cpp_std=c++20 for this module build and set cpp_args to /interface only when meson.get_compiler('cpp').get_id() == 'msvc'.

🤖 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` at 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.

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