feat: Introduce cmakePresets.json in cpp#925
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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.jsonwithdebugandreleaseconfigure/build/test presets. - Updated
cpp/README.mdto document building via CMake presets. - Removed the legacy
build_ubuntu.shandbuild_macos.shscripts.
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 -j8and runs./bgl_examplewithGAR_TEST_DATA=${PWD}/testing. This is inconsistent with the preset workflow (cmake --build --preset ...) and likely won’t work from thecpp/directory because the example binaries are generated under the build tree (typicallybuild/examples/...) and thetestingsubmodule lives at the repo root. Update the snippet to usecmake --build --preset <name>, run the binary via its actual build-path, and pointGAR_TEST_DATAat the correcttesting/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.
| "cacheVariables": { | ||
| "CMAKE_GENERATOR": "Ninja", | ||
| "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", | ||
| "BUILD_TESTS": "ON", | ||
| "BUILD_EXAMPLES": "ON", | ||
| "BUILD_BENCHMARKS": "ON" |
There was a problem hiding this comment.
good suggestions. fixed!
| { | ||
| "name": "base", | ||
| "hidden": true, | ||
| "binaryDir": "${sourceDir}/build", |
| We use CMake Presets for quick building. Available presets: | ||
|
|
| ```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 | ||
| ``` |
…ze builds Signed-off-by: Jason <libevent@yeah.net>
Reason for this PR
This PR is to simplify C++ builds, as discussion in #886.
What changes are included in this PR?
Are these changes tested?
Yes. I have tested on my MacOS
Are there any user-facing changes?
NO