Skip to content

feat: Introduce cmakePresets.json in cpp#925

Open
SYaoJun wants to merge 1 commit into
apache:mainfrom
SYaoJun:cmake_preset
Open

feat: Introduce cmakePresets.json in cpp#925
SYaoJun wants to merge 1 commit into
apache:mainfrom
SYaoJun:cmake_preset

Conversation

@SYaoJun
Copy link
Copy Markdown
Contributor

@SYaoJun SYaoJun commented May 17, 2026

Reason for this PR

This PR is to simplify C++ builds, as discussion in #886.

What changes are included in this PR?

  1. remove MacOS and Ubuntu build scripts.
  2. add CMakePresets.json to unify managing build arguments.
  3. update READEME.md upon build commands.

Are these changes tested?

Yes. I have tested on my MacOS

Are there any user-facing changes?

NO

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.98%. Comparing base (c979f4b) to head (1209a01).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #925      +/-   ##
============================================
+ Coverage     80.86%   80.98%   +0.11%     
  Complexity      615      615              
============================================
  Files            94       94              
  Lines         10742    10744       +2     
  Branches       1060     1062       +2     
============================================
+ Hits           8687     8701      +14     
+ Misses         1815     1803      -12     
  Partials        240      240              
Flag Coverage Δ
cpp 71.74% <ø> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SYaoJun SYaoJun changed the title feat: Introduce cmakePresets.json in cpp to simplify CI feat: Introduce cmakePresets.json in cpp May 19, 2026
@yangxk1 yangxk1 requested a review from Copilot May 19, 2026 05:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a CMake-presets-based workflow for the C++ (cpp/) subproject to simplify and unify build configuration, replacing the existing OS-specific helper scripts.

Changes:

  • Added cpp/CMakePresets.json with debug and release configure/build/test presets.
  • Updated cpp/README.md to document building via CMake presets.
  • Removed the legacy build_ubuntu.sh and build_macos.sh scripts.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
cpp/README.md Replaces script-based quick build docs with CMake preset commands (needs doc fixes for prerequisites/tests/examples).
cpp/CMakePresets.json Adds presets for debug/release configure/build/test (needs generator + build-dir fixes).
cpp/build_ubuntu.sh Removes Ubuntu build helper script.
cpp/build_macos.sh Removes macOS build helper script.
Comments suppressed due to low confidence (1)

cpp/README.md:110

  • The example snippet still invokes make -j8 and runs ./bgl_example with GAR_TEST_DATA=${PWD}/testing. This is inconsistent with the preset workflow (cmake --build --preset ...) and likely won’t work from the cpp/ directory because the example binaries are generated under the build tree (typically build/examples/...) and the testing submodule lives at the repo root. Update the snippet to use cmake --build --preset <name>, run the binary via its actual build-path, and point GAR_TEST_DATA at the correct testing/ directory (e.g., via the git toplevel).
To run examples (examples are built by default with presets):

```bash
make -j8       # if you have 8 CPU cores, otherwise adjust, use -j`nproc` for all cores
GAR_TEST_DATA=${PWD}/testing ./bgl_example  # run the BGL example

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cpp/CMakePresets.json
Comment on lines +13 to +18
"cacheVariables": {
"CMAKE_GENERATOR": "Ninja",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"BUILD_TESTS": "ON",
"BUILD_EXAMPLES": "ON",
"BUILD_BENCHMARKS": "ON"
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

good suggestions. fixed!

Comment thread cpp/CMakePresets.json Outdated
{
"name": "base",
"hidden": true,
"binaryDir": "${sourceDir}/build",
Comment thread cpp/README.md
Comment on lines +93 to 94
We use CMake Presets for quick building. Available presets:

Comment thread cpp/README.md
Comment on lines 98 to 104
```bash
./build_ubuntu.sh
```

**macOS:**
```bash
./build_macos.sh
```
# Configure the project
cmake --preset debug # or: cmake --preset release

These scripts will automatically create the build directory, configure with CMake, and compile the project. Build logs will be saved to `build_ubuntu.log` or `build_macos.log`.

After building, you can run the unit tests with:

```bash
git submodule update --init --recursive # download the testing data
GAR_TEST_DATA=${PWD}/testing ctest
# Build the project
cmake --build --preset debug # or: cmake --build --preset release
```
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

restored

…ze builds

Signed-off-by: Jason <libevent@yeah.net>
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.

3 participants