diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/CMakeLists.txt | 46 |
2 files changed, 27 insertions, 21 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index bedf85819..48a4d91a4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ OPTION( PROFILE "Generate profiling information" OFF ) OPTION( ENABLE_TRACE "Enables tracing support" OFF ) OPTION( LIBGIT2_FILENAME "Name of the produced binary" OFF ) -OPTION( USE_SHA1DC "Use SHA-1 with collision detection" OFF ) +SET(SHA1_BACKEND "CollisionDetection" CACHE STRING "Backend to use for SHA1. One of Generic, OpenSSL, Win32, CommonCrypto, CollisionDetection. ") OPTION( USE_SSH "Link with libssh to enable SSH support" ON ) OPTION( USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON ) OPTION( USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1f69d4f11..c8389c2b8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -122,10 +122,6 @@ ELSE () PKG_CHECK_MODULES(CURL libcurl) ENDIF () - IF (NOT AMIGA AND (USE_HTTPS STREQUAL "OpenSSL" OR USE_HTTPS STREQUAL "ON")) - FIND_PACKAGE(OpenSSL QUIET) - ENDIF () - IF (CURL_FOUND) SET(GIT_CURL 1) LIST(APPEND LIBGIT2_INCLUDES ${CURL_INCLUDE_DIRS}) @@ -178,6 +174,8 @@ IF (USE_HTTPS) LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LIBRARIES} ${SECURITY_LIBRARIES}) LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS}) ELSEIF (HTTPS_BACKEND STREQUAL "OpenSSL") + FIND_PACKAGE(OpenSSL) + IF (NOT OPENSSL_FOUND) MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found") ENDIF() @@ -199,34 +197,42 @@ ELSE() ENDIF() # Specify sha1 implementation -IF (USE_SHA1DC) - ADD_FEATURE_INFO(SHA ON "using SHA1DC") +IF(SHA1_BACKEND STREQUAL "OpenSSL") + IF(NOT OPENSSL_FOUND) + FIND_PACKAGE(OpenSSL) + IF(NOT OPENSSL_FOUND) + MESSAGE(FATAL_ERROR "Requested OpenSSL SHA1 backend, but OpenSSL could not be found") + ENDIF() + ENDIF() + + ADD_FEATURE_INFO(SHA ON "using OpenSSL") + SET(GIT_SHA1_OPENSSL 1) + IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + LIST(APPEND LIBGIT2_PC_LIBS "-lssl") + ELSE() + SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} openssl") + ENDIF() +ELSEIF(SHA1_BACKEND STREQUAL "CollisionDetection") + ADD_FEATURE_INFO(SHA ON "using CollisionDetection") SET(GIT_SHA1_COLLISIONDETECT 1) ADD_DEFINITIONS(-DSHA1DC_NO_STANDARD_INCLUDES=1) ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\") ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\") FILE(GLOB SRC_SHA1 hash/hash_collisiondetect.c hash/sha1dc/*) -ELSEIF (WIN32 AND NOT MINGW) - ADD_FEATURE_INFO(SHA ON "using SHA1_WIN32") +ELSEIF(SHA1_BACKEND STREQUAL "Generic") + ADD_FEATURE_INFO(SHA ON "using Generic") + FILE(GLOB SRC_SHA1 hash/hash_generic.c) +ELSEIF(SHA1_BACKEND STREQUAL "Win32") + ADD_FEATURE_INFO(SHA ON "using Win32") SET(GIT_SHA1_WIN32 1) FILE(GLOB SRC_SHA1 hash/hash_win32.c) -ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") +ELSEIF(SHA1_BACKEND STREQUAL "CommonCrypto") ADD_FEATURE_INFO(SHA ON "using CommonCrypto") SET(GIT_SHA1_COMMON_CRYPTO 1) -ELSEIF (OPENSSL_FOUND) - ADD_FEATURE_INFO(SHA ON "using OpenSSL") - SET(GIT_SHA1_OPENSSL 1) - IF (CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - LIST(APPEND LIBGIT2_PC_LIBS "-lssl") - ELSE() - SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} openssl") - ENDIF () ELSE() - ADD_FEATURE_INFO(SHA ON "using generic") - FILE(GLOB SRC_SHA1 hash/hash_generic.c) + MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend ${SHA1_BACKEND}") ENDIF() - # Include POSIX regex when it is required IF(WIN32 OR AMIGA OR CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") ADD_SUBDIRECTORY("${libgit2_SOURCE_DIR}/deps/regex" "${libgit2_BINARY_DIR}/deps/regex") |