Skip to content

Commit 2a58a9e

Browse files
committed
updated readme
1 parent fe1543d commit 2a58a9e

1 file changed

Lines changed: 87 additions & 21 deletions

File tree

README.md

Lines changed: 87 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,111 @@ Collection of general-purpose C++ functions, classes and utilities
44

55
## Core Library
66

7-
### Installation
7+
| **Dependency** | **Version** | **Description** |
8+
|----------------|-------------|-----------------|
9+
| CMake | >= 3.21 | CMake Build Tool |
10+
| [cmakebox](https://github.com/willat343/cppbox) | >= 0.0.1 | CMake Functions and Utilities |
11+
12+
There are several ways to include `cppbox` within your project:
13+
- [Preferred] Via `FetchContent` allowing `cppbox` to be built as a submodule.
14+
- Via `find_package`, requiring `cppbox` to be installed to the system, locally, or to a catkin workspace.
15+
16+
## Include via FetchContent
17+
18+
It is recommended to leverage the functionality of [cmakebox](https://github.com/willat343/cppbox) by including the following lines in the `CMakeLists.txt` (replace `X.Y.Z` with version):
19+
```CMake
20+
set(CMAKEBOX_VERSION "0.0.1")
21+
FetchContent_Declare(
22+
cmakebox
23+
GIT_REPOSITORY git@github.com:willat343/cmakebox.git
24+
GIT_TAG v${CMAKEBOX_VERSION}
25+
)
26+
FetchContent_MakeAvailable(cmakebox)
27+
list(APPEND CMAKE_MODULE_PATH "${cmakebox_SOURCE_DIR}/cmake")
28+
include(CMakeBox)
29+
30+
set(CPPBOX_VERSION "X.Y.Z")
31+
import_dependency(
32+
cppbox
33+
TARGET cppbox::cppbox
34+
VERSION ${CPPBOX_VERSION}
35+
USE_SYSTEM_REQUIRED_VERSION ${CPPBOX_VERSION}
36+
GIT_REPOSITORY git@github.com:willat343/cppbox
37+
GIT_TAG v${CPPBOX_VERSION}
38+
)
39+
```
40+
41+
Without relying on [cmakebox](https://github.com/willat343/cppbox), this can be achieved with (replace `X.Y.Z` with version):
42+
```CMake
43+
set(CPPBOX_VERSION "X.Y.Z")
44+
FetchContent_Declare(
45+
cppbox
46+
GIT_REPOSITORY git@github.com:willat343/cppbox
47+
GIT_TAG v${CPPBOX_VERSION}
48+
)
49+
FetchContent_MakeAvailable(cppbox)
50+
```
51+
52+
## Include via Install
53+
54+
### Clone
855

956
```bash
1057
git clone git@github.com:willat343/cppbox.git
1158
cd cppbox
12-
cmake -S . -B build -DBUILD_DOCUMENTATION=OFF -DBUILD_TESTS=OFF
59+
```
60+
61+
### Configure
62+
63+
For system install:
64+
```bash
65+
cmake -S . -B build
66+
```
67+
68+
For local install:
69+
```bash
70+
cmake -S . -B build -DCMAKE_INSTALL_DIR=$HOME/.local
71+
```
72+
73+
### Build
74+
75+
```bash
1376
cmake --build build -j
14-
sudo cmake --build build --target install
1577
```
1678

17-
### Uninstallation
79+
### Install
1880

1981
```bash
20-
sudo cmake --build build --target uninstall
82+
sudo cmake --build build --target install
2183
```
2284

23-
### Include in Downstream Project
85+
### Include
2486

25-
In the downstream project's `CMakeLists.txt`:
26-
```cmake
87+
Include with the following lines in the `CMakeLists.txt`:
88+
```CMake
2789
find_package(cppbox REQUIRED)
28-
target_link_libraries(<target> PUBLIC ${cppbox_LIBRARIES})
90+
target_link_libraries(<target> PUBLIC cppbox::cppbox)
2991
```
3092

31-
The `cppbox` provides CMake targets in `${cppbox_LIBRARIES}` which contain the properties (include directories, link libraries, compile options, compile flags, link flags, etc.) needed by the downstream project, and hence only `target_link_libraries()` is required.
93+
### Uninstall
3294

33-
## Catkin Support
95+
```bash
96+
sudo cmake --build build --target uninstall
97+
```
98+
99+
## Include in Catkin Workspace
34100

35101
A `package.xml` is supplied to facilitate an isolated installation within a catkin workspace (e.g. for ROS applications).
36102

37-
### Installation
103+
### Clone
38104

39-
Either:
40-
```bash
41-
ln -s /path/to/cppbox /path/to/catkin_ws/src
42-
```
43-
Or:
44105
```bash
45106
cd /path/to/catkin_ws/src
46107
git clone git@github.com:willat343/cppbox.git
47108
```
48109

49-
Then:
110+
### Build
111+
50112
```bash
51113
cd /path/to/catkin_ws
52114
catkin build cppbox
@@ -59,11 +121,15 @@ cd /path/to/catkin_ws
59121
catkin clean cppbox
60122
```
61123

62-
### Include in Downstream Project
124+
### Include
63125

64126
To use the package in a downstream project, one should add to their `package.xml`:
65127
```xml
66128
<depend>cppbox</depend>
67129
```
68-
One can then either use the workspace's isolated installation or use the system installation otherwise.
69-
Importing the dependency is then exactly the same as it would be in a non-catkin package as described above (do NOT rely on the `catkin` variables like `catkin_LIBRARIES` and `catkin_INCLUDE_DIRS`).
130+
131+
One can then include `cppbox` package by includeing in the `CMakeLists.txt`:
132+
```CMake
133+
find_package(cppbox REQUIRED)
134+
target_link_libraries(<target> PUBLIC cppbox::cppbox)
135+
```

0 commit comments

Comments
 (0)