Skip to content

Commit 26d60e2

Browse files
committed
README updates
1 parent 7fb2c88 commit 26d60e2

1 file changed

Lines changed: 37 additions & 3 deletions

File tree

README.md

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,38 @@ A similar example, but with validation of data can be found [here](src/example/e
9393

9494
This library can be used in a few ways:
9595

96-
A simplest and not recommended way is to copy `src/options` directory to your project and add the files in there to the compilation process either by hand OR by including only this directory via `add_subdirectory`. After all the whole library is just 7 files.
96+
Using cmake the easiest way seems to be using
97+
[FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) mechanism:
9798

98-
Another option is to clone the whole repository and add it via `add_subdirectory`:
99+
```cmake
100+
include(FetchContent)
101+
102+
FetchContent_Declare(
103+
options
104+
GIT_REPOSITORY https://github.com/opokatech/options
105+
GIT_TAG v3.0.0
106+
GIT_SHALLOW TRUE
107+
GIT_PROGRESS TRUE)
108+
FetchContent_MakeAvailable(options)
109+
110+
# ....
111+
112+
add_executable(example my_main.cpp)
113+
target_link_libraries(example PRIVATE options)
114+
```
115+
116+
Another option is to clone the whole repository as a [git submodule](https://git-scm.com/book/en/v2/Git-Tools-Submodules)
117+
and add it via `add_subdirectory`:
118+
119+
```bash
120+
git submodule add https://github.com/opokatech/options externals/options
121+
122+
# optionally checkout some particular version:
123+
cd externals/options
124+
git checkout v3.0.0
125+
```
126+
127+
And then in your CMakeLists.txt:
99128

100129
```cmake
101130
add_subdirectory(external/options) # location of the cloned repository
@@ -104,7 +133,12 @@ add_executable(example my_main.cpp)
104133
target_link_libraries(example PRIVATE options)
105134
```
106135

107-
## Some notes:
136+
And there is of course the most simple and **not recommended** way:
137+
copying `src/options` directory to your project and adding the files from it to
138+
the compilation process. Either by hand OR by including only the `options` directory
139+
via `add_subdirectory`. After all the whole library consists of just 7 files.
140+
141+
## Some notes
108142

109143
* an option may have an argument or not. An option without an argument is a flag,
110144
* an option is always identified by a long name. A long name is used with 2 dashes in front of it,

0 commit comments

Comments
 (0)