Skip to content

Commit 7d403ca

Browse files
committed
DOC: Improve C++ client integration docs
1 parent b9789c6 commit 7d403ca

File tree

3 files changed

+71
-23
lines changed

3 files changed

+71
-23
lines changed

README.md

Lines changed: 69 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
The official C++ client library for [Databento](https://databento.com).
77
The client supports both streaming live and historical data through similar interfaces.
88

9-
**Please note:** this client currently supports historical data and is under active development as Databento prepares to launch live data.
9+
**Please note:** this client currently only supports historical data and is under active development as Databento prepares to launch live data.
1010

1111
## Usage
1212

@@ -41,10 +41,52 @@ These examples can be compiled by enabling the cmake option `DATABENTO_ENABLE_EX
4141

4242
More detailed examples and the full API documentation can be found on the [Databento doc site](https://docs.databento.com/getting-started).
4343

44+
## Integration
45+
46+
databento-cpp can be integrated into C++ projects in a couple of different ways.
47+
48+
### Embedded
49+
50+
The easiest way to integrate databento-cpp into your project is using CMake's [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html).
51+
The minimum supported CMake version is 3.14.
52+
```cmake
53+
include(FetchContent)
54+
55+
FetchContent_Declare(
56+
databento
57+
GIT_REPOSITORY https://github.com/databento/databento-cpp
58+
GIT_TAG HEAD
59+
)
60+
FetchContent_MakeAvailable(databento)
61+
62+
add_library(my_library)
63+
target_link_libraries(my_library PRIVATE databento::databento)
64+
```
65+
66+
### System
67+
68+
To install databento-cpp at the system level, clone the repo, build, and install with CMake.
69+
```sh
70+
git clone https://github.com/databento/databento-cpp
71+
cd databento-cpp
72+
cmake -S . -B build \
73+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
74+
-DCMAKE_INSTALL_PREFIX='/usr'
75+
cmake --build build --target databento
76+
cmake --install build
77+
```
78+
79+
Then in your project's `CMakeLists.txt`, add the following:
80+
```cmake
81+
find_package(databento 0.1.0 REQUIRED)
82+
add_library(my_library)
83+
target_link_libraries(my_library PRIVATE databento::databento)
84+
```
85+
4486
## Requirements
4587

46-
The minimum C++ standard is C++11.
47-
Dependencies:
88+
The minimum C++ standard is C++11 and CMake 3.14.
89+
The library has the following dependencies:
4890
- [cpp-httplib (header only)](https://github.com/yhirose/cpp-httplib)
4991
- OpenSSL
5092
- [nlohmann_json (header only)](https://github.com/nlohmann/json)
@@ -54,7 +96,13 @@ By default, cpp-httplib and nlohmann_json are downloaded by CMake as part of the
5496
If you would like to use a local version of these libraries, enable the CMake flag
5597
`DATABENTO_ENABLE_EXTERNAL_HTTPLIB` or `DATABENTO_ENABLE_EXTERNAL_JSON`.
5698

57-
## Building
99+
The other two dependencies (zstd and OpenSSL) are available in most package managers.
100+
For example, on Ubuntu and Debian:
101+
```sh
102+
sudo apt install libssl-dev libzstd-dev
103+
```
104+
105+
## Building locally
58106

59107
databento-cpp uses [CMake](https://cmake.org/) as its build system, with a minimum version of 3.14.
60108
Building with `cmake` is a two step process: first configuring, then building.
@@ -63,7 +111,7 @@ cmake -S . -B build # configure
63111
cmake --build build -- -j $(nproc) # build all targets with all cores
64112
```
65113

66-
## Testing
114+
### Testing
67115

68116
Tests are located in the `test` directory.
69117
They're written using [GoogleTest (gtest)](https://github.com/google/googletest).
@@ -74,7 +122,7 @@ cmake --build build --target databentoTests # build
74122
build/test/databentoTests # run
75123
```
76124

77-
## Formatting
125+
### Formatting
78126

79127
databento-cpp uses [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) with Google's style.
80128
`clang-format` usually comes installed with [clang](https://clang.llvm.org/).
@@ -83,33 +131,33 @@ You can run `clang-format` against all the files in `databento-cpp` with the fol
83131
cmake --build build --target clang-format
84132
```
85133

86-
## Linting
134+
### Linting
87135

88-
databento-cpp uses clang-tidy for linting and detecting potential mistakes.
89-
To run clang-tidy, run the following command:
136+
databento-cpp uses Clang-Tidy and Cppcheck for linting and detecting potential mistakes.
137+
Both can be enabled to run as part of compilation through CMake flags.
90138
```sh
91-
cmake -S . -B build # configure to create compile_commands.json
92-
run-clang-tidy -p build
139+
cmake -S . -B build -DDATABENTO_ENABLE_CLANG_TIDY=1 -DDATABENTO_ENABLE_CPPCHECK=1
140+
cmake --build build # compiles code, and runs Clang-Tidy and Cppcheck
93141
```
94142

95-
## macOS
143+
### macOS
96144

97-
On macOS, the best way to install clang-tidy and clang-format is to install all of LLVM and symlink
98-
the binaries to some place in your `PATH`.
145+
To setup OpenSSL and zstd, run the following:
146+
```sh
147+
brew install openssl zstd
148+
# Add it to the PATH so cmake can find it
149+
export "$PATH:$HOMEBREW_PREFIX/opt/openssl/bin"
150+
```
151+
152+
For linting on macOS, the best way to install clang-tidy and clang-format is to install all of LLVM
153+
and symlink the binaries to some place in your `PATH`.
99154
```sh
100155
brew install llvm
101156
ln -s $(brew --prefix llvm)/bin/clang-tidy $HOME/.local/bin/
102157
ln -s $(brew --prefix llvm)/bin/clang-format $HOME/.local/bin/
103158
ln -s $(brew --prefix llvm)/bin/run-clang-format $HOME/.local/bin/
104159
```
105160

106-
To setup OpenSSL, run the following:
107-
```sh
108-
brew install openssl
109-
# Add it to the PATH so cmake can find it
110-
export "$PATH:$HOMEBREW_PREFIX/opt/openssl/bin"
111-
```
112-
113161
## License
114162

115163
Distributed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0.html).

example/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.13)
1+
cmake_minimum_required(VERSION 3.14)
22

33
#
44
# Project details

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.13)
1+
cmake_minimum_required(VERSION 3.14)
22

33
#
44
# Project details

0 commit comments

Comments
 (0)