Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 32 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,20 @@ else()
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# Find dependencies
find_package(OpenSSL REQUIRED)
# Optional OpenSSL dependency (prefer native SSL if available)
option(LLMCPP_USE_OPENSSL "Use OpenSSL instead of native SSL" OFF)

if(LLMCPP_USE_OPENSSL)
find_package(OpenSSL QUIET)
if(OpenSSL_FOUND)
message(STATUS "llmcpp: Using OpenSSL for HTTPS")
else()
message(WARNING "llmcpp: OpenSSL requested but not found, falling back to native SSL")
set(LLMCPP_USE_OPENSSL OFF)
endif()
else()
message(STATUS "llmcpp: Using native SSL (SecureTransport on macOS, WinSSL on Windows)")
endif()

# Use FetchContent for dependencies
include(FetchContent)
Expand All @@ -50,10 +62,24 @@ FetchContent_Declare(
GIT_TAG v0.15.3
)

# Configure httplib to use OpenSSL and disable unnecessary features
set(HTTPLIB_USE_OPENSSL ON)
set(HTTPLIB_USE_ZLIB OFF CACHE BOOL "" FORCE)
set(HTTPLIB_USE_BROTLI OFF CACHE BOOL "" FORCE)
# Configure httplib SSL and disable unnecessary features
set(HTTPLIB_USE_ZLIB OFF CACHE BOOL "Use zlib" FORCE)
set(HTTPLIB_USE_BROTLI OFF CACHE BOOL "Use Brotli" FORCE)

if(LLMCPP_USE_OPENSSL AND OpenSSL_FOUND)
# Use OpenSSL
set(HTTPLIB_USE_OPENSSL ON CACHE BOOL "Use OpenSSL" FORCE)
set(HTTPLIB_USE_SECURE_TRANSPORT OFF CACHE BOOL "Use SecureTransport" FORCE)
set(HTTPLIB_USE_WINSSL OFF CACHE BOOL "Use WinSSL" FORCE)
else()
# Use native SSL
set(HTTPLIB_USE_OPENSSL OFF CACHE BOOL "Use OpenSSL" FORCE)
if(APPLE)
set(HTTPLIB_USE_SECURE_TRANSPORT ON CACHE BOOL "Use SecureTransport on macOS" FORCE)
elseif(WIN32)
set(HTTPLIB_USE_WINSSL ON CACHE BOOL "Use WinSSL on Windows" FORCE)
endif()
endif()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: SSL Configuration Breaks Linux HTTPS Support

The SSL configuration changes introduce two issues. When LLMCPP_USE_OPENSSL is enabled and OpenSSL is found, the required OpenSSL libraries (OpenSSL::SSL, OpenSSL::Crypto) are not linked, causing linker errors. Additionally, on Linux, if LLMCPP_USE_OPENSSL is OFF, httplib lacks an SSL backend since the native SSL fallback only supports macOS and Windows, breaking HTTPS functionality.

Fix in Cursor Fix in Web


# Make dependencies available
FetchContent_MakeAvailable(nlohmann_json httplib)
Expand Down Expand Up @@ -97,8 +123,6 @@ target_link_libraries(llmcpp
nlohmann_json
PRIVATE
httplib::httplib
OpenSSL::SSL
OpenSSL::Crypto
)

# Platform-specific libraries
Expand Down
Loading