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

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new f0c74f64c Fix: make cpp binding build robust (#6460)
f0c74f64c is described below

commit f0c74f64c1a39ad40359018535f5bd53183271b5
Author: Huanbing <[email protected]>
AuthorDate: Wed Aug 20 22:59:41 2025 +0800

    Fix: make cpp binding build robust (#6460)
    
    * fix: make robust cpp binding build
    
    * fix: make robust cpp binding build
    
    * fix: make robust cpp binding build
---
 .vscode/settings.json                  | 16 ++++++++++++++--
 bindings/cpp/CMakeLists.txt            | 20 ++++++++++++--------
 bindings/cpp/README.md                 |  9 +++++++--
 bindings/cpp/include/opendal_async.hpp |  1 -
 4 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/.vscode/settings.json b/.vscode/settings.json
index caabcfce4..bf83498e5 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -1,7 +1,11 @@
 {
   "rust-analyzer.cargo.allTargets": true,
   "rust-analyzer.cargo.features": "all",
-  "rust-analyzer.procMacro.ignored": { "napi-derive": ["napi"] },
+  "rust-analyzer.procMacro.ignored": {
+    "napi-derive": [
+      "napi"
+    ]
+  },
   "rust-analyzer.linkedProjects": [
     "${workspaceFolder}/core/Cargo.toml",
     "${workspaceFolder}/bindings/python/Cargo.toml",
@@ -12,5 +16,13 @@
     "${workspaceFolder}/bin/ofs/Cargo.toml"
   ],
   "java.compile.nullAnalysis.mode": "automatic",
-  "cmake.ignoreCMakeListsMissing": true
+  "cmake.ignoreCMakeListsMissing": true,
+  "clangd.arguments": [
+    "--background-index=true",
+    "--pch-storage=memory",
+    "--header-insertion=never",
+    "--clang-tidy",
+    "--cross-file-rename=true",
+    "--compile-commands-dir=${workspaceFolder}/bindings/cpp/build/"
+  ]
 }
diff --git a/bindings/cpp/CMakeLists.txt b/bindings/cpp/CMakeLists.txt
index c1ab0f364..6d3755048 100644
--- a/bindings/cpp/CMakeLists.txt
+++ b/bindings/cpp/CMakeLists.txt
@@ -17,7 +17,7 @@
 
 cmake_minimum_required(VERSION 3.22)
 
-# CMP0135: set the timestamps of all extracted contents 
+# CMP0135: set the timestamps of all extracted contents
 # to the time of the extraction in FetchContent
 if (POLICY CMP0135)
     cmake_policy(SET CMP0135 NEW)
@@ -28,6 +28,7 @@ project(opendal-cpp LANGUAGES CXX)
 include(FetchContent)
 set(OPENDAL_GOOGLETEST_VERSION 1.15.2 CACHE STRING "version of GoogleTest, 
'external' to fallback to find_package()")
 set(OPENDAL_CPPCORO_VERSION a4ef65281814b18fdd1ac5457d3e219347ec6cb8 CACHE 
STRING "version of cppcoro")
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 
 if (NOT CMAKE_BUILD_TYPE)
     set(CMAKE_BUILD_TYPE Debug)
@@ -102,11 +103,11 @@ set(CPP_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include
                     ${PROJECT_SOURCE_DIR}/src
                     ${CARGO_TARGET_DIR}/cxxbridge
                     ${CARGO_TARGET_DIR}/cxxbridge/opendal-cpp/src)
-file(GLOB CPP_SOURCE_FILE 
+file(GLOB CPP_SOURCE_FILE
     "src/*.cpp"
-    "src/utils/*.cpp"    
+    "src/utils/*.cpp"
 )
-file(GLOB CPP_HEADER_FILE 
+file(GLOB CPP_HEADER_FILE
     "include/*.hpp"
     "src/*.hpp"
     "src/utils/*.hpp"
@@ -114,7 +115,7 @@ file(GLOB CPP_HEADER_FILE
 if (NOT OPENDAL_ENABLE_ASYNC)
     file (GLOB ASYNC_SOURCE_FILE "src/*async*.cpp")
     list(REMOVE_ITEM CPP_SOURCE_FILE ${ASYNC_SOURCE_FILE})
-    
+
     file(GLOB ASYNC_HEADER_FILE "include/*async*.hpp")
     list(REMOVE_ITEM CPP_HEADER_FILE ${ASYNC_HEADER_FILE})
 endif()
@@ -179,7 +180,7 @@ endif()
 # Tests
 if (OPENDAL_ENABLE_TESTING)
     enable_testing()
-    
+
     if(OPENDAL_GOOGLETEST_VERSION STREQUAL "external")
         find_package(GTest REQUIRED)
     else()
@@ -199,19 +200,22 @@ if (OPENDAL_ENABLE_TESTING)
             URL 
https://github.com/andreasbuhr/cppcoro/archive/${OPENDAL_CPPCORO_VERSION}.zip
         )
         FetchContent_MakeAvailable(cppcoro)
+        target_compile_options(cppcoro PRIVATE
+            "-Wno-deprecated-this-capture"
+        )
     endif()
 
     list(APPEND TEST_SOURCE_FILE tests/basic_test.cpp tests/metadata_test.cpp 
tests/test_main.cpp)
     if (OPENDAL_ENABLE_ASYNC)
         list(APPEND TEST_SOURCE_FILE tests/async_test.cpp)
     endif()
-    
+
     # Behavior tests
     list(APPEND TEST_SOURCE_FILE tests/behavior/read_test.cpp)
     list(APPEND TEST_SOURCE_FILE tests/behavior/write_test.cpp)
     list(APPEND TEST_SOURCE_FILE tests/behavior/delete_test.cpp)
     list(APPEND TEST_SOURCE_FILE tests/behavior/list_test.cpp)
-    
+
     # Async behavior tests (only if async is enabled)
     if (OPENDAL_ENABLE_ASYNC)
         list(APPEND TEST_SOURCE_FILE tests/behavior/async_read_test.cpp)
diff --git a/bindings/cpp/README.md b/bindings/cpp/README.md
index 5c4a898cc..2c8a240ec 100644
--- a/bindings/cpp/README.md
+++ b/bindings/cpp/README.md
@@ -69,6 +69,7 @@ Support for more package managers is coming soon!
 
 - CMake >= 3.22
 - C++ compiler with C++17 support
+- **Currently only Clang or AppleClang are supported**
 
 ### Build
 
@@ -76,10 +77,14 @@ Support for more package managers is coming soon!
 mkdir build
 cd build
 # Add -DOPENDAL_DEV=ON to make development environment for OpenDAL
-cmake ..
+cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
 make
 ```
 
+### Dev Setup
+
+We provide a default VSCode configuration in `.vscode/settings.json` at the 
project root. After installing the clangd extension in VSCode, restart the 
editor to enable proper code completion and IntelliSense support.
+
 ### Test
 
 You should build the project with `OPENDAL_ENABLE_TESTING` option. Then run:
@@ -103,7 +108,7 @@ make docs
 - `OPENDAL_ENABLE_DOCUMENTATION`: Enable documentation. Default: `OFF`
 - `OPENDAL_DOCS_ONLY`: Only build documentation. Default: `OFF`
 - `OPENDAL_ENABLE_TESTING`: Enable testing. Default: `OFF`
-- `OPENDAL_ENABLE_ASYNC`: Enable async support. Default: `OFF`
+- `OPENDAL_ENABLE_ASYNC`: Enable async support. Requires Clang or AppleClang 
with C++20. Default: `OFF`
 - `OPENDAL_FEATURES`: Specify OpenDAL services to include, like 
`"opendal/services-s3,opendal/services-memory"`. Default: `""`
 
 ## License and Trademarks
diff --git a/bindings/cpp/include/opendal_async.hpp 
b/bindings/cpp/include/opendal_async.hpp
index e3e422272..c819d218a 100644
--- a/bindings/cpp/include/opendal_async.hpp
+++ b/bindings/cpp/include/opendal_async.hpp
@@ -27,7 +27,6 @@
 #include <unordered_map>
 
 #include "async.rs.h"
-#include "async_defs.hpp"
 
 namespace opendal::async {
 

Reply via email to