update installation guide for the C++ version
The installation is now possible using cmake
This commit is contained in:
parent
06d4484d8a
commit
a0a84f99c4
|
@ -43,5 +43,67 @@ template: overrides/main.html
|
|||
```
|
||||
|
||||
=== "C++"
|
||||
As of now it it only possible to use the sources directly by adding them to your
|
||||
project. There will be a version on `conan` in the future
|
||||
There are severals ways to integrate `rapidfuzz` in your CMake project.
|
||||
|
||||
## By Installing it
|
||||
```bash
|
||||
git clone https://github.com/maxbachmann/rapidfuzz-cpp.git rapidfuzz-cpp
|
||||
cd rapidfuzz-cpp
|
||||
mkdir build && cd build
|
||||
cmake ..
|
||||
cmake --build .
|
||||
cmake --build . --target install
|
||||
```
|
||||
|
||||
Then in your CMakeLists.txt:
|
||||
```cmake
|
||||
find_package(rapidfuzz REQUIRED)
|
||||
add_executable(foo main.cpp)
|
||||
target_link_libraries(foo rapidfuzz::rapidfuzz)
|
||||
```
|
||||
|
||||
## Add this repository as a submodule
|
||||
```bash
|
||||
git submodule add https://github.com/maxbachmann/rapidfuzz-cpp.git 3rdparty/RapidFuzz
|
||||
```
|
||||
Then you can either:
|
||||
|
||||
1. include it as a subdirectory
|
||||
```cmake
|
||||
add_subdirectory(3rdparty/RapidFuzz)
|
||||
add_executable(foo main.cpp)
|
||||
target_link_libraries(foo rapidfuzz::rapidfuzz)
|
||||
```
|
||||
2. build it at configure time with `FetchContent`
|
||||
```cmake
|
||||
FetchContent_Declare(
|
||||
rapidfuzz
|
||||
SOURCE_DIR ${CMAKE_SOURCE_DIR}/3rdparty/RapidFuzz
|
||||
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/rapidfuzz
|
||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> "${CMAKE_OPT_ARGS}"
|
||||
)
|
||||
FetchContent_MakeAvailable(rapidfuzz)
|
||||
add_executable(foo main.cpp)
|
||||
target_link_libraries(foo PRIVATE rapidfuzz::rapidfuzz)
|
||||
```
|
||||
## Download it at configure time
|
||||
|
||||
If you don't want to add `rapidfuzz-cpp` as a submodule, you can also download it with `FetchContent`:
|
||||
```cmake
|
||||
FetchContent_Declare(rapidfuzz
|
||||
GIT_REPOSITORY https://github.com/maxbachmann/rapidfuzz-cpp.git
|
||||
GIT_TAG master)
|
||||
FetchContent_MakeAvailable(rapidfuzz)
|
||||
add_executable(foo main.cpp)
|
||||
target_link_libraries(foo PRIVATE rapidfuzz::rapidfuzz)
|
||||
```
|
||||
It will be downloaded each time you run CMake in a blank folder.
|
||||
|
||||
## CMake options
|
||||
|
||||
There are the following CMake options:
|
||||
|
||||
1. `BUILD_TESTS` : to build test (default OFF and requires [Catch2](https://github.com/catchorg/Catch2))
|
||||
|
||||
2. `BUILD_BENCHMARKS` : to build benchmarks (default OFF and requires [Google Benchmark](https://github.com/google/benchmark))
|
||||
|
||||
|
|
Loading…
Reference in New Issue