Skip to content

Commit ef70e00

Browse files
committed
Add support for wolfssl
1 parent 22a41e6 commit ef70e00

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

CMakeLists.txt

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,11 @@ cpr_option(CPR_CURL_USE_LIBPSL "Since curl 8.13 curl depends on libpsl (https://
6161
cpr_option(CPR_USE_SYSTEM_LIB_PSL "If enabled we will use the psl lib already installed on this system. Else meson is required as build dependency. Only relevant in case 'CPR_CURL_USE_LIBPSL' is set to ON." ${CPR_USE_SYSTEM_CURL})
6262
cpr_option(CPR_ENABLE_CURL_HTTP_ONLY "If enabled we will only use the HTTP/HTTPS protocols from CURL. If disabled, all the CURL protocols are enabled. This is useful if your project uses libcurl and you need support for other CURL features e.g. sending emails." ON)
6363
cpr_option(CPR_ENABLE_SSL "Enables or disables the SSL backend. Required to perform HTTPS requests." ON)
64-
cpr_option(CPR_FORCE_OPENSSL_BACKEND "Force to use the OpenSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, and CPR_FORCE_WINSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
65-
cpr_option(CPR_FORCE_WINSSL_BACKEND "Force to use the WinSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, and CPR_FORCE_WINSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
66-
cpr_option(CPR_FORCE_DARWINSSL_BACKEND "Force to use the DarwinSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, and CPR_FORCE_WINSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
67-
cpr_option(CPR_FORCE_MBEDTLS_BACKEND "Force to use the Mbed TLS backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, and CPR_FORCE_WINSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
64+
cpr_option(CPR_FORCE_OPENSSL_BACKEND "Force to use the OpenSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, CPR_FORCE_WINSSL_BACKEND and CPR_FORCE_WOLFSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
65+
cpr_option(CPR_FORCE_WINSSL_BACKEND "Force to use the WinSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, CPR_FORCE_WINSSL_BACKEND and CPR_FORCE_WOLFSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
66+
cpr_option(CPR_FORCE_DARWINSSL_BACKEND "Force to use the DarwinSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, CPR_FORCE_WINSSL_BACKEND and CPR_FORCE_WOLFSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
67+
cpr_option(CPR_FORCE_MBEDTLS_BACKEND "Force to use the Mbed TLS backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, CPR_FORCE_WINSSL_BACKEND and CPR_FORCE_WOLFSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
68+
cpr_option(CPR_FORCE_WOLFSSL_BACKEND "Force to use the WolfSSL backend. If CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, CPR_FORCE_WINSSL_BACKEND and CPR_FORCE_WOLFSSL_BACKEND are set to to OFF, cpr will try to automatically detect the best available SSL backend (WinSSL - Windows, OpenSSL - Linux, DarwinSSL - Mac ...)." OFF)
6869
cpr_option(CPR_ENABLE_LINTING "Set to ON to enable clang linting." OFF)
6970
cpr_option(CPR_ENABLE_CPPCHECK "Set to ON to enable Cppcheck static analysis. Requires CPR_BUILD_TESTS and CPR_BUILD_TESTS_SSL to be OFF to prevent checking google tests source code." OFF)
7071
cpr_option(CPR_BUILD_TESTS "Set to ON to build cpr tests." OFF)
@@ -125,8 +126,8 @@ endif()
125126

126127
# SSL
127128
if(CPR_ENABLE_SSL)
128-
if(CPR_FORCE_OPENSSL_BACKEND OR CPR_FORCE_WINSSL_BACKEND OR CPR_FORCE_DARWINSSL_BACKEND OR CPR_FORCE_MBEDTLS_BACKEND)
129-
message(STATUS "Disabled SSL backend auto detect since either CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, or CPR_FORCE_WINSSL_BACKEND is enabled.")
129+
if(CPR_FORCE_OPENSSL_BACKEND OR CPR_FORCE_WINSSL_BACKEND OR CPR_FORCE_DARWINSSL_BACKEND OR CPR_FORCE_MBEDTLS_BACKEND OR CPR_FORCE_WOLFSSL_BACKEND)
130+
message(STATUS "Disabled SSL backend auto detect since either CPR_FORCE_OPENSSL_BACKEND, CPR_FORCE_DARWINSSL_BACKEND, CPR_FORCE_MBEDTLS_BACKEND, CPR_FORCE_WINSSL_BACKEND, or CPR_FORCE_WOLFSSL_BACKEND is enabled.")
130131
set(DETECT_SSL_BACKEND OFF CACHE INTERNAL "" FORCE)
131132
else()
132133
message(STATUS "Automatically detecting SSL backend.")
@@ -156,7 +157,12 @@ if(CPR_ENABLE_SSL)
156157
if(MBEDTLS_FOUND)
157158
set(SSL_BACKEND_USED "MbedTLS")
158159
else()
159-
message(FATAL_ERROR "No valid SSL backend found! Please install OpenSSL, Mbed TLS or disable SSL by setting CPR_ENABLE_SSL to OFF.")
160+
find_package(WolfSSL)
161+
if(WOLFSSL_FOUND)
162+
set(SSL_BACKEND_USED "WolfSSL")
163+
else()
164+
message(FATAL_ERROR "No valid SSL backend found! Please install OpenSSL, Mbed TLS or disable SSL by setting CPR_ENABLE_SSL to OFF.")
165+
endif()
160166
endif()
161167
endif()
162168
endif()
@@ -180,6 +186,10 @@ if(CPR_ENABLE_SSL)
180186
message(STATUS "Using Mbed TLS.")
181187
set(CPR_BUILD_TESTS_SSL OFF)
182188
set(SSL_BACKEND_USED "MbedTLS")
189+
elseif(CPR_FORCE_WOLFSSL_BACKEND)
190+
message(STATUS "Using WolfSSL.")
191+
set(CPR_BUILD_TESTS_SSL OFF)
192+
set(SSL_BACKEND_USED "WolfSSL")
183193
endif()
184194
endif()
185195
endif()
@@ -281,6 +291,10 @@ else()
281291
set(CURL_USE_MBEDTLS ON CACHE INTERNAL "" FORCE)
282292
endif()
283293

294+
if(SSL_BACKEND_USED STREQUAL "WolfSSL")
295+
set(CURL_USE_WOLFSSL ON CACHE INTERNAL "" FORCE)
296+
endif()
297+
284298
message(STATUS "Enabled curl SSL")
285299
else()
286300
set(CURL_ENABLE_SSL OFF CACHE INTERNAL "" FORCE)

0 commit comments

Comments
 (0)