Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 496771e

Browse files
committed
cmake: move Darwin-specific block around
This allows us to only link against CoreFoundation when using the SecureTransport backend
1 parent 9ef26a9 commit 496771e

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
@@ -53,12 +53,6 @@ OPTION( USE_EXT_HTTP_PARSER "Use system HTTP_Parser if available" ON)
5353
OPTION( DEBUG_POOL "Enable debug pool allocator" OFF )
5454
OPTION( ENABLE_WERROR "Enable compilation with -Werror" OFF )
5555

56-
IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
57-
SET( USE_ICONV ON )
58-
FIND_PACKAGE(Security)
59-
FIND_PACKAGE(CoreFoundation REQUIRED)
60-
ENDIF()
61-
6256
IF(MSVC)
6357
# This option is only available when building with MSVC. By default, libgit2
6458
# 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
@@ -92,11 +92,6 @@ IF(THREADSAFE)
9292
ENDIF()
9393
ADD_FEATURE_INFO(threadsafe THREADSAFE "threadsafe support")
9494

95-
IF (COREFOUNDATION_FOUND)
96-
LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LIBRARIES})
97-
LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS})
98-
ENDIF()
99-
10095

10196
IF (WIN32 AND EMBED_SSH_PATH)
10297
FILE(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
@@ -128,7 +123,7 @@ ELSE ()
128123
ENDIF ()
129124

130125
IF (NOT AMIGA AND (USE_HTTPS STREQUAL "OpenSSL" OR USE_HTTPS STREQUAL "ON"))
131-
FIND_PACKAGE(OpenSSL)
126+
FIND_PACKAGE(OpenSSL QUIET)
132127
ENDIF ()
133128

134129
IF (CURL_FOUND)
@@ -142,6 +137,11 @@ ELSE ()
142137
ENDIF()
143138

144139
IF (USE_HTTPS)
140+
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
141+
FIND_PACKAGE(Security)
142+
FIND_PACKAGE(CoreFoundation)
143+
ENDIF()
144+
145145
# Auto-select TLS backend
146146
IF (USE_HTTPS STREQUAL ON)
147147
IF (SECURITY_FOUND)
@@ -163,6 +163,9 @@ IF (USE_HTTPS)
163163

164164
# Check that we can find what's required for the selected backend
165165
IF (HTTPS_BACKEND STREQUAL "SecureTransport")
166+
IF (NOT COREFOUNDATION_FOUND)
167+
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found")
168+
ENDIF()
166169
IF (NOT SECURITY_FOUND)
167170
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, Security.framework not found")
168171
ENDIF()
@@ -172,8 +175,8 @@ IF (USE_HTTPS)
172175

173176
SET(GIT_SECURE_TRANSPORT 1)
174177
LIST(APPEND LIBGIT2_INCLUDES ${SECURITY_INCLUDE_DIR})
175-
LIST(APPEND LIBGIT2_LIBS ${SECURITY_LIBRARIES})
176-
LIST(APPEND LIBGIT2_PC_LIBS ${SECURITY_LDFLAGS})
178+
LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LIBRARIES} ${SECURITY_LIBRARIES})
179+
LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
177180
ELSEIF (HTTPS_BACKEND STREQUAL "OpenSSL")
178181
IF (NOT OPENSSL_FOUND)
179182
MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
@@ -298,7 +301,7 @@ ENDIF()
298301
ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support")
299302

300303
# Optional external dependency: iconv
301-
IF (USE_ICONV)
304+
IF (USE_ICONV OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
302305
FIND_PACKAGE(Iconv)
303306
ENDIF()
304307
IF (ICONV_FOUND)

0 commit comments

Comments
 (0)