Skip to content

Commit

Permalink
docs(bindings/cpp): add more using details about cmake (#3155)
Browse files Browse the repository at this point in the history
Signed-off-by: silver-ymz <[email protected]>
  • Loading branch information
silver-ymz authored Sep 21, 2023
1 parent 23f05b9 commit 5791b6b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 19 deletions.
2 changes: 1 addition & 1 deletion bindings/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ else()
endif()
set(CPP_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/include ${CARGO_TARGET_DIR}/cxxbridge/opendal-cpp/src)
file(GLOB_RECURSE CPP_SOURCE_FILE src/*.cpp)
file(GLOB_RECURSE CPP_HEADER_FILE include/*.h)
file(GLOB_RECURSE CPP_HEADER_FILE include/*.hpp)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_custom_command(
Expand Down
3 changes: 1 addition & 2 deletions bindings/cpp/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@
# specific language governing permissions and limitations
# under the License.

PROJECT_NAME = "OpenDAL Cpp Binding"
PROJECT_NAME = "OpenDAL-CPP"
PROJECT_BRIEF = "The Cpp binding for Apache OpenDAL"
OUTPUT_DIRECTORY = @CMAKE_CURRENT_BINARY_DIR@/docs_doxygen/
EXCLUDE_SYMBOLS = ""
USE_MDFILE_AS_MAINPAGE = "README.md"

DOXYFILE_ENCODING = UTF-8
CREATE_SUBDIRS = NO
CREATE_SUBDIRS_LEVEL = 8
Expand Down
60 changes: 44 additions & 16 deletions bindings/cpp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

![](https://github.com/apache/incubator-opendal/assets/5351546/87bbf6e5-f19e-449a-b368-3e283016c887)

Documents: [![Documents](https://img.shields.io/badge/opendal-cpp-blue?logo=Apache&logoColor=red)](https://opendal.apache.org/docs/cpp/)

## Example

```cpp
Expand All @@ -16,6 +18,47 @@ int main() {
}
```

More examples can be found [here](../../examples/cpp).

## Using

### CMake

You can use `FetchContent` to add OpenDAL to your project.

```cmake
FetchContent_Declare(
opendal-cpp
GIT_REPOSITORY https://github.com/apache/incubator-opendal.git
GIT_TAG v0.40.0
SOURCE_SUBDIR bindings/cpp
)
FetchContent_MakeAvailable(opendal-cpp)
```

Or you can download the source code and add it to your project.

```shell
mkdir third_party
cd third_party
git clone https://github.com/apache/incubator-opendal.git
git checkout v0.40.0
```

```cmake
add_subdirectory(third_party/incubator-opendal/bindings/cpp)
```

Now you can use OpenDAL in your project.

```cmake
target_link_libraries(your_target opendal_cpp)
```

### Others

Support for more package managers is coming soon!

## Compiling

### Prerequisites
Expand Down Expand Up @@ -56,19 +99,4 @@ make docs
- `OPENDAL_ENABLE_ADDRESS_SANITIZER`: Enable address sanitizer. Default: `OFF`
- `OPENDAL_ENABLE_DOCUMENTATION`: Enable documentation. Default: `OFF`
- `OPENDAL_DOCS_ONLY`: Only build documentation. Default: `OFF`
- `OPENDAL_ENABLE_TESTING`: Enable testing. Default: `OFF`

## Using

### CMake

Because the project repo includes rust core code, we can't use `git submodule` directly to add it. So we recommend using `FetchContent` to add the library.

```cmake
FetchContent_Declare(
opendal-cpp
URL https://github.com/apache/incubator-opendal/releases/download/<newest-tag>/opendal-cpp-<newest-tag>.tar.gz
URL_HASH SHA256=<newest-tag-sha256>
)
FetchContent_MakeAvailable(opendal-cpp)
```
- `OPENDAL_ENABLE_TESTING`: Enable testing. Default: `OFF`

0 comments on commit 5791b6b

Please sign in to comment.