@@ -30,6 +30,21 @@ else()
3030 add_compile_options (-Wall -Wextra -Wpedantic )
3131endif ()
3232
33+ # Optional OpenSSL dependency (prefer native SSL if available)
34+ option (LLMCPP_USE_OPENSSL "Use OpenSSL instead of native SSL" OFF )
35+
36+ if (LLMCPP_USE_OPENSSL)
37+ find_package (OpenSSL QUIET )
38+ if (OpenSSL_FOUND)
39+ message (STATUS "llmcpp: Using OpenSSL for HTTPS" )
40+ else ()
41+ message (WARNING "llmcpp: OpenSSL requested but not found, falling back to native SSL" )
42+ set (LLMCPP_USE_OPENSSL OFF )
43+ endif ()
44+ else ()
45+ message (STATUS "llmcpp: Using native SSL (SecureTransport on macOS, WinSSL on Windows)" )
46+ endif ()
47+
3348# Use FetchContent for dependencies
3449include (FetchContent )
3550
@@ -47,19 +62,23 @@ FetchContent_Declare(
4762 GIT_TAG v0.15.3
4863)
4964
50- # Configure httplib to use native SSL and disable unnecessary features
51- # - macOS: Uses SecureTransport (via Security framework)
52- # - Windows: Uses WinSSL/Schannel (via crypt32)
53- # - Linux: Would need OpenSSL, but we primarily target macOS/Windows
54- set (HTTPLIB_USE_OPENSSL OFF CACHE BOOL "Use OpenSSL" FORCE )
65+ # Configure httplib SSL and disable unnecessary features
5566set (HTTPLIB_USE_ZLIB OFF CACHE BOOL "Use zlib" FORCE )
5667set (HTTPLIB_USE_BROTLI OFF CACHE BOOL "Use Brotli" FORCE )
5768
58- # Enable platform-specific SSL
59- if (APPLE )
60- set (HTTPLIB_USE_SECURE_TRANSPORT ON CACHE BOOL "Use SecureTransport on macOS" FORCE )
61- elseif (WIN32 )
62- set (HTTPLIB_USE_WINSSL ON CACHE BOOL "Use WinSSL on Windows" FORCE )
69+ if (LLMCPP_USE_OPENSSL AND OpenSSL_FOUND)
70+ # Use OpenSSL
71+ set (HTTPLIB_USE_OPENSSL ON CACHE BOOL "Use OpenSSL" FORCE )
72+ set (HTTPLIB_USE_SECURE_TRANSPORT OFF CACHE BOOL "Use SecureTransport" FORCE )
73+ set (HTTPLIB_USE_WINSSL OFF CACHE BOOL "Use WinSSL" FORCE )
74+ else ()
75+ # Use native SSL
76+ set (HTTPLIB_USE_OPENSSL OFF CACHE BOOL "Use OpenSSL" FORCE )
77+ if (APPLE )
78+ set (HTTPLIB_USE_SECURE_TRANSPORT ON CACHE BOOL "Use SecureTransport on macOS" FORCE )
79+ elseif (WIN32 )
80+ set (HTTPLIB_USE_WINSSL ON CACHE BOOL "Use WinSSL on Windows" FORCE )
81+ endif ()
6382endif ()
6483
6584# Make dependencies available
0 commit comments