This is an automated email from the ASF dual-hosted git repository.

yangxk1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-graphar.git


The following commit(s) were added to refs/heads/main by this push:
     new d93c7755 feat: Introduce cmakePresets.json in cpp (#925)
d93c7755 is described below

commit d93c77559500ff13c0391ee94ab3d60bb06f7200
Author: Jason <[email protected]>
AuthorDate: Mon May 25 19:52:38 2026 +0800

    feat: Introduce cmakePresets.json in cpp (#925)
    
    * feat: Introduce cmakePresets.json in cpp to simplify CI and standardize 
builds
    
    Signed-off-by: Jason <[email protected]>
    
    * fix: install ninja on MacOS
    
    Signed-off-by: Jason <[email protected]>
    
    ---------
    
    Signed-off-by: Jason <[email protected]>
---
 cpp/CMakePresets.json | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++
 cpp/README.md         | 37 ++++++++++++++---------------
 cpp/build_macos.sh    | 27 ---------------------
 cpp/build_ubuntu.sh   | 24 -------------------
 4 files changed, 84 insertions(+), 70 deletions(-)

diff --git a/cpp/CMakePresets.json b/cpp/CMakePresets.json
new file mode 100644
index 00000000..0095873e
--- /dev/null
+++ b/cpp/CMakePresets.json
@@ -0,0 +1,66 @@
+{
+  "version": 4,
+  "cmakeMinimumRequired": {
+    "major": 3,
+    "minor": 21,
+    "patch": 0
+  },
+  "configurePresets": [
+    {
+      "name": "base",
+      "hidden": true,
+      "generator": "Ninja",
+      "binaryDir": "${sourceDir}/build_${presetName}",
+      "cacheVariables": {
+        "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
+        "BUILD_TESTS": "ON",
+        "BUILD_EXAMPLES": "ON",
+        "BUILD_BENCHMARKS": "ON"
+      }
+    },
+    {
+      "name": "debug",
+      "inherits": ["base"],
+      "displayName": "Debug Build",
+      "description": "Build GraphAr with debug configuration",
+      "cacheVariables": {
+        "CMAKE_BUILD_TYPE": "Debug"
+      }
+    },
+    {
+      "name": "release",
+      "inherits": ["base"],
+      "displayName": "Release Build",
+      "description": "Build GraphAr with release configuration",
+      "cacheVariables": {
+        "CMAKE_BUILD_TYPE": "Release"
+      }
+    }
+  ],
+  "buildPresets": [
+    {
+      "name": "debug",
+      "configurePreset": "debug"
+    },
+    {
+      "name": "release",
+      "configurePreset": "release"
+    }
+  ],
+  "testPresets": [
+    {
+      "name": "debug",
+      "configurePreset": "debug",
+      "output": {
+        "outputOnFailure": true
+      }
+    },
+    {
+      "name": "release",
+      "configurePreset": "release",
+      "output": {
+        "outputOnFailure": true
+      }
+    }
+  ]
+}
diff --git a/cpp/README.md b/cpp/README.md
index 02473507..d08db427 100644
--- a/cpp/README.md
+++ b/cpp/README.md
@@ -33,6 +33,7 @@ Dependencies for optional features:
 - [BGL](https://www.boost.org/doc/libs/1_80_0/libs/graph/doc/index.html) (>= 
1.58)
 - [Google Benchmark](https://github.com/google/benchmark) (>= 1.6.0) for 
benchmarking
 - [Catch2](https://github.com/catchorg/Catch2) v3 for unit testing
+- [Ninja](https://github.com/ninja-build/ninja) required for CMake presets
 
 On Ubuntu/Debian, you can install the required packages with:
 
@@ -41,7 +42,8 @@ sudo apt-get install \
     build-essential \
     cmake \
     libboost-graph-dev \
-    doxygen
+    doxygen\
+    ninja-build
 
 # Arrow C++ dependencies
 wget -c \
@@ -53,7 +55,12 @@ sudo apt-get install -y libarrow-dev libarrow-dataset-dev 
libarrow-acero-dev lib
 ```
 
 On macOS, you can use [Homebrew](https://brew.sh) to install the required 
packages:
+
 ```bash
+# Minimal install for building with CMake presets:
+brew install ninja cmake
+
+# Or install all development dependencies:
 brew update && brew bundle --file=cpp/Brewfile
 ```
 
@@ -88,27 +95,21 @@ cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=ON ..
 make -j8       # if you have 8 CPU cores, otherwise adjust, use -j`nproc` for 
all cores
 ```
 
-### Quick Build with Scripts
+### Quick Build with CMake Presets
 
-For convenience, we provide build scripts for Ubuntu and macOS that configure 
the following CMake options:
+We use CMake Presets for quick building. Available presets:
 
-- `-DBUILD_BENCHMARKS=ON`: Build benchmark executables
-- `-DCMAKE_BUILD_TYPE=Debug`: Build in debug mode
-- `-DBUILD_TESTS=ON`: Build unit tests
-- `-DBUILD_EXAMPLES=ON`: Build example executables
+- `debug` - Debug build with tests, examples, and benchmarks
+- `release` - Release build with tests, examples, and benchmarks
 
-**Ubuntu:**
 ```bash
-./build_ubuntu.sh
-```
+# Configure the project
+cmake --preset debug    # or: cmake --preset release
 
-**macOS:**
-```bash
-./build_macos.sh
+# Build the project
+cmake --build --preset debug    # or: cmake --build --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
@@ -116,17 +117,15 @@ git submodule update --init --recursive  # download the 
testing data
 GAR_TEST_DATA=${PWD}/testing ctest
 ```
 
-Build with examples, you should build the project with `BUILD_EXAMPLES` 
option, then run:
+Build with examples, you should build the project with `BUILD_EXAMPLES` 
option(examples are built by default with presets), then run:
 
 ```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
 ```
 
-Build with benchmarks, you should build the project with `BUILD_BENCHMARKS` 
option, then run:
+Build with benchmarks, you should build the project with `BUILD_BENCHMARKS` 
option(benchmarks are built by default with presets), then run:
 
 ```bash
-make -j8       # if you have 8 CPU cores, otherwise adjust, use -j`nproc` for 
all cores
 GAR_TEST_DATA=${PWD}/testing ./graph_info_benchmark  # run the graph info 
benchmark
 ```
 
diff --git a/cpp/build_macos.sh b/cpp/build_macos.sh
deleted file mode 100644
index 119e2491..00000000
--- a/cpp/build_macos.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-# Change this line to your arrow and parquet include path if needed
-export CPATH="/opt/homebrew/include:$CPATH"
-
-cmake -S . -B build_macos \
-    -DBUILD_BENCHMARKS=ON \
-    -DCMAKE_BUILD_TYPE=Debug \
-    -DBUILD_TESTS=ON \
-    -DBUILD_EXAMPLES=ON
-
-cmake --build build_macos -j8 2>&1 | tee build_macos.log
\ No newline at end of file
diff --git a/cpp/build_ubuntu.sh b/cpp/build_ubuntu.sh
deleted file mode 100644
index 82697a09..00000000
--- a/cpp/build_ubuntu.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-cmake -S . -B build_ubuntu \
-    -DBUILD_BENCHMARKS=ON \
-    -DCMAKE_BUILD_TYPE=Debug \
-    -DBUILD_TESTS=ON \
-    -DBUILD_EXAMPLES=ON
-
-cmake --build build_ubuntu -j8 2>&1 | tee build_ubuntu.log
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to