cmake: move Darwin-specific block around This allows us to only link against CoreFoundation when using the SecureTransport backend
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8f16443..58032ac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -56,12 +56,6 @@ IF (UNIX AND NOT APPLE)
OPTION( ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF )
ENDIF()
-IF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
- SET( USE_ICONV ON )
- FIND_PACKAGE(Security)
- FIND_PACKAGE(CoreFoundation REQUIRED)
-ENDIF()
-
IF(MSVC)
# This option is only available when building with MSVC. By default, libgit2
# is build using the cdecl calling convention, which is useful if you're
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e81dfb1..3c04f8a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -97,11 +97,6 @@ IF(THREADSAFE)
ENDIF()
ADD_FEATURE_INFO(threadsafe THREADSAFE "threadsafe support")
-IF (COREFOUNDATION_FOUND)
- LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LIBRARIES})
- LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS})
-ENDIF()
-
IF (WIN32 AND EMBED_SSH_PATH)
FILE(GLOB SRC_SSH "${EMBED_SSH_PATH}/src/*.c")
@@ -133,7 +128,7 @@ ELSE ()
ENDIF ()
IF (NOT AMIGA AND (USE_HTTPS STREQUAL "OpenSSL" OR USE_HTTPS STREQUAL "ON"))
- FIND_PACKAGE(OpenSSL)
+ FIND_PACKAGE(OpenSSL QUIET)
ENDIF ()
IF (CURL_FOUND)
@@ -147,6 +142,11 @@ ELSE ()
ENDIF()
IF (USE_HTTPS)
+ IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ FIND_PACKAGE(Security)
+ FIND_PACKAGE(CoreFoundation)
+ ENDIF()
+
# Auto-select TLS backend
IF (USE_HTTPS STREQUAL ON)
IF (SECURITY_FOUND)
@@ -168,6 +168,9 @@ IF (USE_HTTPS)
# Check that we can find what's required for the selected backend
IF (HTTPS_BACKEND STREQUAL "SecureTransport")
+ IF (NOT COREFOUNDATION_FOUND)
+ MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found")
+ ENDIF()
IF (NOT SECURITY_FOUND)
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, Security.framework not found")
ENDIF()
@@ -177,8 +180,8 @@ IF (USE_HTTPS)
SET(GIT_SECURE_TRANSPORT 1)
LIST(APPEND LIBGIT2_INCLUDES ${SECURITY_INCLUDE_DIR})
- LIST(APPEND LIBGIT2_LIBS ${SECURITY_LIBRARIES})
- LIST(APPEND LIBGIT2_PC_LIBS ${SECURITY_LDFLAGS})
+ LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LIBRARIES} ${SECURITY_LIBRARIES})
+ LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
ELSEIF (HTTPS_BACKEND STREQUAL "OpenSSL")
IF (NOT OPENSSL_FOUND)
MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
@@ -303,7 +306,7 @@ ENDIF()
ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support")
# Optional external dependency: iconv
-IF (USE_ICONV)
+IF (USE_ICONV OR CMAKE_SYSTEM_NAME MATCHES "Darwin")
FIND_PACKAGE(Iconv)
ENDIF()
IF (ICONV_FOUND)