Skip to content

Commit c9bb68c

Browse files
committed
cmake: move Darwin-specific block around
This allows us to only link against CoreFoundation when using the SecureTransport backend
1 parent 9980be0 commit c9bb68c

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ IF (UNIX AND NOT APPLE)
5656
OPTION( ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF )
5757
ENDIF()
5858

59-
IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
60-
SET( USE_ICONV ON )
61-
FIND_PACKAGE(Security)
62-
FIND_PACKAGE(CoreFoundation REQUIRED)
63-
ENDIF()
64-
6559
IF(MSVC)
6660
# This option is only available when building with MSVC. By default, libgit2
6761
# is build using the cdecl calling convention, which is useful if you're

src/CMakeLists.txt

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,6 @@ IF(THREADSAFE)
9797
ENDIF()
9898
ADD_FEATURE_INFO(threadsafe THREADSAFE "threadsafe support")
9999

100-
IF (COREFOUNDATION_FOUND)
101-
LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LIBRARIES})
102-
LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS})
103-
ENDIF()
104-
105100

106101
IF (WIN32 AND EMBED_SSH_PATH)
107102
FILE(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
@@ -133,7 +128,7 @@ ELSE ()
133128
ENDIF ()
134129

135130
IF (NOT AMIGA AND (USE_HTTPS STREQUAL "OpenSSL" OR USE_HTTPS STREQUAL "ON"))
136-
FIND_PACKAGE(OpenSSL)
131+
FIND_PACKAGE(OpenSSL QUIET)
137132
ENDIF ()
138133

139134
IF (CURL_FOUND)
@@ -147,6 +142,11 @@ ELSE ()
147142
ENDIF()
148143

149144
IF (USE_HTTPS)
145+
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
146+
FIND_PACKAGE(Security)
147+
FIND_PACKAGE(CoreFoundation)
148+
ENDIF()
149+
150150
# Auto-select TLS backend
151151
IF (USE_HTTPS STREQUAL ON)
152152
IF (SECURITY_FOUND)
@@ -168,6 +168,9 @@ IF (USE_HTTPS)
168168

169169
# Check that we can find what's required for the selected backend
170170
IF (HTTPS_BACKEND STREQUAL "SecureTransport")
171+
IF (NOT COREFOUNDATION_FOUND)
172+
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found")
173+
ENDIF()
171174
IF (NOT SECURITY_FOUND)
172175
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, Security.framework not found")
173176
ENDIF()
@@ -177,8 +180,8 @@ IF (USE_HTTPS)
177180

178181
SET(GIT_SECURE_TRANSPORT 1)
179182
LIST(APPEND LIBGIT2_INCLUDES ${SECURITY_INCLUDE_DIR})
180-
LIST(APPEND LIBGIT2_LIBS ${SECURITY_LIBRARIES})
181-
LIST(APPEND LIBGIT2_PC_LIBS ${SECURITY_LDFLAGS})
183+
LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LIBRARIES} ${SECURITY_LIBRARIES})
184+
LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
182185
ELSEIF (HTTPS_BACKEND STREQUAL "OpenSSL")
183186
IF (NOT OPENSSL_FOUND)
184187
MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
@@ -303,7 +306,7 @@ ENDIF()
303306
ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support")
304307

305308
# Optional external dependency: iconv
306-
IF (USE_ICONV)
309+
IF (USE_ICONV OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
307310
FIND_PACKAGE(Iconv)
308311
ENDIF()
309312
IF (ICONV_FOUND)

0 commit comments

Comments
 (0)