@@ -87,7 +87,39 @@ if (LLAMA_CURL)
8787 target_compile_definitions (${TARGET} PUBLIC LLAMA_USE_CURL)
8888 include_directories (${CURL_INCLUDE_DIRS} )
8989 set (LLAMA_COMMON_EXTRA_LIBS ${LLAMA_COMMON_EXTRA_LIBS} ${CURL_LIBRARIES} )
90- endif ()
90+ else ()
91+ find_package (OpenSSL)
92+ if (OpenSSL_FOUND)
93+ include (CheckCSourceCompiles)
94+ set (CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR} )
95+ check_c_source_compiles("
96+ #include <openssl/opensslv.h>
97+ #if defined(OPENSSL_IS_BORINGSSL) || defined(LIBRESSL_VERSION_NUMBER)
98+ # if OPENSSL_VERSION_NUMBER < 0x1010107f
99+ # error bad version
100+ # endif
101+ #else
102+ # if OPENSSL_VERSION_NUMBER < 0x30000000L
103+ # error bad version
104+ # endif
105+ #endif
106+ int main() { return 0; }
107+ " OPENSSL_VERSION_SUPPORTED)
108+ if (OPENSSL_VERSION_SUPPORTED)
109+ message (STATUS "OpenSSL found: ${OPENSSL_VERSION} " )
110+ target_compile_definitions (${TARGET} PUBLIC CPPHTTPLIB_OPENSSL_SUPPORT)
111+ target_link_libraries (${TARGET} PUBLIC OpenSSL::SSL OpenSSL::Crypto)
112+ if (APPLE AND CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
113+ target_compile_definitions (${TARGET} PUBLIC CPPHTTPLIB_USE_CERTS_FROM_MACOSX_KEYCHAIN)
114+ find_library (CORE_FOUNDATION_FRAMEWORK CoreFoundation REQUIRED)
115+ find_library (SECURITY_FRAMEWORK Security REQUIRED)
116+ target_link_libraries (${TARGET} PUBLIC ${CORE_FOUNDATION_FRAMEWORK} ${SECURITY_FRAMEWORK} )
117+ endif ()
118+ endif ()
119+ else ()
120+ message (STATUS "OpenSSL not found, SSL support disabled" )
121+ endif ()
122+ endif ()
91123
92124if (LLAMA_LLGUIDANCE)
93125 include (ExternalProject)
0 commit comments