1 # Select a hash backend
5 # USE_SHA1=CollisionDetection(ON)/HTTPS/Generic/OFF
8 IF(USE_SHA1 STREQUAL ON OR USE_SHA1 STREQUAL "CollisionDetection")
9 SET(SHA1_BACKEND "CollisionDetection")
10 ELSEIF(USE_SHA1 STREQUAL "HTTPS")
11 message(STATUS "Checking HTTPS backend… ${HTTPS_BACKEND}")
12 IF(HTTPS_BACKEND STREQUAL "SecureTransport")
13 SET(SHA1_BACKEND "CommonCrypto")
14 ELSEIF(HTTPS_BACKEND STREQUAL "WinHTTP")
15 SET(SHA1_BACKEND "Win32")
17 SET(SHA1_BACKEND ${HTTPS_BACKEND})
21 SET(SHA1_BACKEND "CollisionDetection")
23 message(STATUS "Using SHA1 backend ${SHA1_BACKEND}")
24 ELSEIF(USE_SHA1 STREQUAL "Generic")
25 SET(SHA1_BACKEND "Generic")
26 # ELSEIF(NOT USE_SHA1)
28 MESSAGE(FATAL_ERROR "Invalid value for USE_SHA1: ${USE_SHA1}")
31 IF(SHA1_BACKEND STREQUAL "CollisionDetection")
32 SET(GIT_SHA1_COLLISIONDETECT 1)
33 ADD_DEFINITIONS(-DSHA1DC_NO_STANDARD_INCLUDES=1)
34 ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\")
35 ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\")
36 FILE(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
37 ELSEIF(SHA1_BACKEND STREQUAL "OpenSSL")
38 # OPENSSL_FOUND should already be set, we're checking HTTPS_BACKEND
40 SET(GIT_SHA1_OPENSSL 1)
41 IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
42 LIST(APPEND LIBGIT2_PC_LIBS "-lssl")
44 LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
46 FILE(GLOB SRC_SHA1 hash/sha1/openssl.*)
47 ELSEIF(SHA1_BACKEND STREQUAL "CommonCrypto")
48 SET(GIT_SHA1_COMMON_CRYPTO 1)
49 FILE(GLOB SRC_SHA1 hash/sha1/common_crypto.*)
50 ELSEIF(SHA1_BACKEND STREQUAL "mbedTLS")
51 SET(GIT_SHA1_MBEDTLS 1)
52 FILE(GLOB SRC_SHA1 hash/sha1/mbedtls.*)
53 LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
54 LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
55 # mbedTLS has no pkgconfig file, hence we can't require it
56 # https://github.com/ARMmbed/mbedtls/issues/228
57 # For now, pass its link flags as our own
58 LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
59 ELSEIF(SHA1_BACKEND STREQUAL "Win32")
61 FILE(GLOB SRC_SHA1 hash/sha1/win32.*)
62 ELSEIF(SHA1_BACKEND STREQUAL "Generic")
63 FILE(GLOB SRC_SHA1 hash/sha1/generic.*)
64 # ELSEIF(NOT USE_SHA1)
66 MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${SHA1_BACKEND}")
69 ADD_FEATURE_INFO(SHA ON "using ${SHA1_BACKEND}")