Skip to content

Commit af17c4c

Browse files
committed
Expand README
1 parent 44ee247 commit af17c4c

File tree

1 file changed

+83
-8
lines changed

1 file changed

+83
-8
lines changed

README.md

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ Try DynamicLoader in [Compiler Explorer](https://godbolt.org/z/KvGxYhErh).
2222
* Linux only
2323
* Does not support function overloads in the loaded library
2424

25-
## Usage
25+
## Example
2626

2727
```C++
28+
#include <DynamicLoader/DynamicLoader.hpp>
29+
2830
try {
29-
auto dynamic_loader = DynamicLoader{"<path/to/lib>"};
31+
auto dynamic_loader = dl::DynamicLoader{"<path/to/lib>"};
3032
auto mangled_name = dynamic_loader.Mangle("Square");
3133
auto function = dynamic_loader.Lookup<int(int)>(mangled_name);
3234
assert(function(2) == 4);
@@ -37,10 +39,83 @@ try {
3739

3840
## Configuration options
3941

40-
| Name | Description |
41-
|-------------------------------|-----------------------------------------------------------------------|
42-
| DynamicLoader_BUILD_DOCS | Build the documentation (requires [Doxygen](https://www.doxygen.nl/)) |
43-
| DynamicLoader_BUILD_TESTS | Build the tests |
44-
| DynamicLoader_ENABLE_WARNINGS | Enable compiler warnings |
42+
| Name | Description | Default |
43+
|------------------------------------|----------------------------------|---------------------------|
44+
| `DynamicLoader_BUILD_DOCS` | Build the documentation | `$PROJECT_IS_TOP_LEVEL` |
45+
| `DynamicLoader_BUILD_TESTS` | Build the tests | `$PROJECT_IS_TOP_LEVEL` |
46+
| `DynamicLoader_ENABLE_WARNINGS` | Enable compiler warnings | `$PROJECT_IS_TOP_LEVEL` |
47+
| `DynamicLoader_CONFIG_INSTALL_DIR` | Install path for package configs | `lib/cmake/DynamicLoader` |
48+
49+
## Building
50+
51+
DynamicLoader uses the [CMake](https://cmake.org/) build system, and [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake) for its (optional) dependencies.
52+
You need CMake >= 3.24.0, Clang >= 12, or GCC >= 9 to build the library.
53+
54+
```Bash
55+
cmake -B build [-GNinja] [-DCMAKE_BUILD_TYPE=Release]
56+
cmake --build build [--config Release]
57+
cmake --install build [--config Release] [--prefix build/prefix]
58+
```
59+
60+
## Testing
61+
62+
DynamicLoader uses [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html) and [doctest](https://github.com/doctest/doctest) for its unit tests.
63+
64+
```Bash
65+
cd build
66+
ctest [-C Release]
67+
```
68+
69+
## Documentation
70+
71+
DynamicLoader uses [Doxygen](https://www.doxygen.nl/) and [Doxygen Awesome](https://github.com/jothepro/doxygen-awesome-css) for its documentation.
72+
73+
```Bash
74+
cmake --build build --target DynamicLoaderDocs
75+
```
76+
77+
Please find the HTML documentation in `build/docs/html`
4578

46-
Uses [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake), [doctest](https://github.com/doctest/doctest), and [Doxygen Awesome](https://github.com/jothepro/doxygen-awesome-css).
79+
## Usage
80+
81+
DynamicLoader can be integrated in your project in several ways.
82+
83+
### CMake FetchContent
84+
85+
```CMake
86+
include(FetchContent)
87+
FetchContent_Declare(
88+
dynamic-loader
89+
GIT_REPOSITORY https://github.com/globberwops/dynamic-loader.git
90+
GIT_TAG <tag>
91+
)
92+
FetchContent_MakeAvailable(dynamic-loader)
93+
...
94+
target_link_libraries(<your-target> PRIVATE DynamicLoader::DynamicLoader)
95+
```
96+
97+
### Git submodules
98+
99+
```Bash
100+
git submodule add https://github.com/globberwops/dynamic-loader.git third_party/dynamic-loader
101+
cd third_party/dynamic-loader
102+
git checkout <tag>
103+
```
104+
105+
```CMake
106+
add_subdirectory(third_party/dynamic-loader EXCLUDE_FROM_ALL)
107+
...
108+
target_link_libraries(<your-target> PRIVATE DynamicLoader::DynamicLoader)
109+
```
110+
111+
### Vcpkg
112+
113+
```Bash
114+
vcpkg install dynamic-loader
115+
```
116+
117+
```CMake
118+
find_package(DynamicLoader CONFIG REQUIRED)
119+
...
120+
target_link_libraries(<your-target> PRIVATE DynamicLoader::DynamicLoader)
121+
```

0 commit comments

Comments
 (0)