mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 01:08:27 +00:00
Bringing Cmake back (#470)
* Revert "Removed CMakeLists.txt. (Fix #421)"
This reverts commit 8674555b88
.
* Fail if cmake version too old
Previous behaviour is just a warning.
* Improve CMakeLists
Adds automatic dependency finding (if they were used).
Adds a way to require a specific version in the find_package(httplib) call.
You should link against the httplib::httplib IMPORTED target, which is
created automatically.
Add options to allow for strictly requiring OpenSSL/ZLIB
HTTPLIB_REQUIRE_OPENSSL & HTTPLIB_REQUIRE_ZLIB require the libs be found, or the build fails.
HTTPLIB_USE_OPENSSL_IF_AVAILABLE & HTTPLIB_USE_ZLIB_IF_AVAILABLE silently search for the libs.
If they aren't found, the build still continues, but shuts off support for those features.
* Add documentation to CMakeLists.txt
Has info on all the available options and what targets are produced.
Also put some things about installation on certain platforms.
This commit is contained in:
parent
29fd136afd
commit
9505a76491
2 changed files with 198 additions and 0 deletions
38
httplibConfig.cmake.in
Normal file
38
httplibConfig.cmake.in
Normal file
|
@ -0,0 +1,38 @@
|
|||
# Generates a macro to auto-configure everything
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
|
||||
# We add find_dependency calls here to not make the end-user have to call them.
|
||||
find_dependency(Threads REQUIRED)
|
||||
if(@HTTPLIB_REQUIRE_OPENSSL@)
|
||||
find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@ REQUIRED)
|
||||
# Lets you check if these options were correctly enabled for your install
|
||||
set(HTTPLIB_IS_USING_OPENSSL TRUE)
|
||||
elseif(@HTTPLIB_USE_OPENSSL_IF_AVAILABLE@)
|
||||
# Look quietly since it's optional
|
||||
find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@ QUIET)
|
||||
# Lets you check if these options were correctly enabled for your install
|
||||
set(HTTPLIB_IS_USING_OPENSSL @OPENSSL_FOUND@)
|
||||
else()
|
||||
set(HTTPLIB_IS_USING_OPENSSL FALSE)
|
||||
endif()
|
||||
if(@HTTPLIB_REQUIRE_ZLIB@)
|
||||
find_dependency(ZLIB REQUIRED)
|
||||
# Lets you check if these options were correctly enabled for your install
|
||||
set(HTTPLIB_IS_USING_ZLIB TRUE)
|
||||
elseif(@HTTPLIB_USE_ZLIB_IF_AVAILABLE@)
|
||||
# Look quietly since it's optional
|
||||
find_dependency(ZLIB QUIET)
|
||||
# Lets you check if these options were correctly enabled for your install
|
||||
set(HTTPLIB_IS_USING_ZLIB @ZLIB_FOUND@)
|
||||
else()
|
||||
set(HTTPLIB_IS_USING_ZLIB FALSE)
|
||||
endif()
|
||||
|
||||
# Lets the end-user find the header path if needed
|
||||
# This is helpful if you're using Cmake's pre-compiled header feature
|
||||
set_and_check(HTTPLIB_HEADER_PATH "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@/httplib.h")
|
||||
|
||||
# Brings in the target library
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/httplibTargets.cmake")
|
Loading…
Add table
Add a link
Reference in a new issue