Skip to content

Commit 9e2c083

Browse files
author
guy levy
committed
📝 add documentation to CMake find-package support libcpr#645
1 parent ab6ec0b commit 9e2c083

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

+18
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ For a quick overview about the planed features, have a look at the next [Milesto
7474
7575
### CMake
7676
77+
#### fetch_content:
7778
If you already have a CMake project you need to integrate C++ Requests with, the primary way is to use `fetch_content`.
7879
Add the following to your `CMakeLists.txt`.
7980
@@ -95,6 +96,23 @@ That should do it!
9596
There's no need to handle `libcurl` yourself. All dependencies are taken care of for you.
9697
All of this can be found in an example [**here**](https://github.com/libcpr/example-cmake-fetch-content).
9798

99+
#### find_package():
100+
If you prefer not to use `fetch_content`, you can download, build, and install the library and then use CMake `find-package()` function to integrate it into a project.
101+
102+
**Note:** this feature is feasible only if CPR_USE_SYSTEM_CURL is set. (see [#645](https://github.com/libcpr/cpr/pull/645))
103+
```Bash
104+
$ git clone https://github.com/libcpr/cpr.git
105+
$ cd cpr && mkdir build && cd build
106+
$ cmake .. -DCPR_USE_SYSTEM_CURL=ON
107+
$ make -j
108+
$ sudo make install
109+
```
110+
In your `CMakeLists.txt`:
111+
```cmake
112+
find_package(cpr REQUIRED)
113+
add_executable(your_target_name your_target_name.cpp)
114+
target_link_libraries(your_target_name PRIVATE cpr::cpr)
115+
```
98116
### Packages for Linux Distributions
99117

100118
Alternatively, you may install a package specific to your Linux distribution. Since so few distributions currently have a package for cpr, most users will not be able to run your program with this approach.

0 commit comments

Comments
 (0)