Add HTTPLIB_COMPILE option to Cmake (#493)

This option (default OFF) automatically splits the file (with split.py)
into a header & source file, then compiles it as a shared/static
library. This requires an installed Python v3 executable to work.

This also adds a HTTPLIB_IS_COMPILED boolean that's available after a
finfind_package(httplib) call.

Note that the minimum Cmake version increased to 3.12 because of FindPython3.
Hopefully this isn't a problem, as it's already 3 years old at this point.
This commit is contained in:
KTGH 2020-05-24 16:07:44 -04:00 committed by GitHub
parent be7962f140
commit 8cad160c0a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 112 additions and 47 deletions

View file

@ -1,33 +1,28 @@
# Generates a macro to auto-configure everything
@PACKAGE_INIT@
# Setting these here so they're accessible after install.
# Might be useful for some users to check which settings were used.
set(HTTPLIB_IS_USING_OPENSSL @HTTPLIB_IS_USING_OPENSSL@)
set(HTTPLIB_IS_USING_ZLIB @HTTPLIB_IS_USING_ZLIB@)
set(HTTPLIB_IS_COMPILED @HTTPLIB_COMPILE@)
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)
if(@HTTPLIB_IS_USING_OPENSSL@)
# OpenSSL COMPONENTS were added in Cmake v3.11
if(CMAKE_VERSION VERSION_LESS "3.11")
find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@ REQUIRED)
else()
# Once the COMPONENTS were added, they were made optional when not specified.
# Since we use both, we need to search for both.
find_dependency(OpenSSL @_HTTPLIB_OPENSSL_MIN_VER@ COMPONENTS Crypto SSL REQUIRED)
endif()
endif()
if(@HTTPLIB_REQUIRE_ZLIB@)
if(@HTTPLIB_IS_USING_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