Skip to content

Commit f408a4e

Browse files
committed
Update README to add Cmake information
Adds some basic build & installation information. Adds the list of special vars available after find_package. Also adds a small note on how to use precompiled headers.
1 parent 477572e commit f408a4e

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,44 @@ cli.set_compress(true);
512512
res = cli.Post("/resource/foo", "...", "text/plain");
513513
```
514514

515+
Building & Installation (Cmake)
516+
-------------------------------
517+
518+
After installation with Cmake, a `find_package(httplib)` is available.
519+
This creates a `httplib::httplib` target (if found).
520+
It can be linked like so:
521+
```cmake
522+
target_link_libraries(your_exe httplib::httplib)
523+
```
524+
525+
The following will build & install for later use.
526+
527+
Linux/macOS
528+
```shell
529+
mkdir -p build
530+
cd build
531+
cmake -DCMAKE_BUILD_TYPE=Release ..
532+
sudo cmake --build . --target install
533+
```
534+
Windows
535+
```cmd
536+
mkdir build
537+
cd build
538+
cmake ..
539+
runas /user:Administrator "cmake --build . --config Release --target install"
540+
```
541+
542+
These three variables are available after you run `find_package(httplib)`
543+
* `HTTPLIB_HEADER_PATH` - this is the full path to the installed header.
544+
* `HTTPLIB_IS_USING_OPENSSL` - a bool for if OpenSSL support is enabled.
545+
* `HTTPLIB_IS_USING_ZLIB` - a bool for if ZLIB support is enabled.
546+
547+
Want to use precompiled headers (Cmake feature since v3.16)?
548+
It's as simple as doing the following (before linking):
549+
```cmake
550+
target_precompile_headers(httplib::httplib INTERFACE "${HTTPLIB_HEADER_PATH}")
551+
```
552+
515553
Split httplib.h into .h and .cc
516554
-------------------------------
517555

0 commit comments

Comments
 (0)