Skip to content

Commit 1b00061

Browse files
committed
CMake: fall back to OpenSSL on older OS X
Starting at OS X 10.8, the Security framework offers some functions which are unified across OS X and iOS. These are the functions that we use. Older versions of OS X do not have these functions and we fail to compile. In these situations, fall back to using OpenSSL for our TLS stream instead.
1 parent c2549ee commit 1b00061

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

CMakeLists.txt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,18 @@ STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION ([0-9]+)$" "\\1" LIBGIT2_SOVERSION "$
152152
INCLUDE_DIRECTORIES(src include)
153153

154154
IF (SECURITY_FOUND)
155-
MESSAGE("-- Found Security ${SECURITY_DIRS}")
156-
LIST(APPEND LIBGIT2_PC_LIBS "-framework Security")
155+
# OS X 10.7 and older do not have some functions we use, fall back to OpenSSL there
156+
CHECK_LIBRARY_EXISTS("${SECURITY_DIRS}" SSLCreateContext "Security/SecureTransport.h" HAVE_NEWER_SECURITY)
157+
IF (HAVE_NEWER_SECURITY)
158+
MESSAGE("-- Found Security ${SECURITY_DIRS}")
159+
LIST(APPEND LIBGIT2_PC_LIBS "-framework Security")
160+
ELSE()
161+
MESSAGE("-- Security framework is too old, falling back to OpenSSL")
162+
SET(SECURITY_FOUND "NO")
163+
SET(SECURITY_DIRS "")
164+
SET(SECURITY_DIR "")
165+
SET(USE_OPENSSL "ON")
166+
ENDIF()
157167
ENDIF()
158168

159169
IF (COREFOUNDATION_FOUND)

0 commit comments

Comments
 (0)