Skip to content

Commit 2c15414

Browse files
committed
cmake: move sha1 source selection into CMakeLists.txt
The select hashes module selects the hash; the CMakeLists.txt selects the files to implement it.
1 parent c7f6ecb commit 2c15414

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

cmake/SelectHashes.cmake

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ if(USE_SHA1 STREQUAL "CollisionDetection")
2424
add_definitions(-DSHA1DC_NO_STANDARD_INCLUDES=1)
2525
add_definitions(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\")
2626
add_definitions(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\")
27-
file(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
2827
elseif(USE_SHA1 STREQUAL "OpenSSL")
2928
# OPENSSL_FOUND should already be set, we're checking USE_HTTPS
3029

@@ -34,29 +33,20 @@ elseif(USE_SHA1 STREQUAL "OpenSSL")
3433
else()
3534
list(APPEND LIBGIT2_PC_REQUIRES "openssl")
3635
endif()
37-
file(GLOB SRC_SHA1 hash/sha1/openssl.*)
3836
elseif(USE_SHA1 STREQUAL "CommonCrypto")
3937
set(GIT_SHA1_COMMON_CRYPTO 1)
40-
file(GLOB SRC_SHA1 hash/sha1/common_crypto.*)
4138
elseif(USE_SHA1 STREQUAL "mbedTLS")
4239
set(GIT_SHA1_MBEDTLS 1)
43-
file(GLOB SRC_SHA1 hash/sha1/mbedtls.*)
4440
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
45-
list(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
41+
list(APPEND LIBGIT2_SYSTEM_LIBS ${MBEDTLS_LIBRARIES})
4642
# mbedTLS has no pkgconfig file, hence we can't require it
4743
# https://github.com/ARMmbed/mbedtls/issues/228
4844
# For now, pass its link flags as our own
4945
list(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
5046
elseif(USE_SHA1 STREQUAL "Win32")
5147
set(GIT_SHA1_WIN32 1)
52-
file(GLOB SRC_SHA1 hash/sha1/win32.*)
53-
elseif(USE_SHA1 STREQUAL "Generic")
54-
file(GLOB SRC_SHA1 hash/sha1/generic.*)
55-
else()
48+
elseif(NOT (USE_SHA1 STREQUAL "Generic"))
5649
message(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}")
5750
endif()
5851

59-
list(APPEND SRC_SHA1 "hash/sha1.h")
60-
list(SORT SRC_SHA1)
61-
6252
add_feature_info(SHA ON "using ${USE_SHA1}")

src/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,21 @@ include(SelectSSH)
9797
include(SelectWinHTTP)
9898
include(SelectZlib)
9999

100+
101+
if(USE_SHA1 STREQUAL "CollisionDetection")
102+
file(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
103+
elseif(USE_SHA1 STREQUAL "OpenSSL")
104+
file(GLOB SRC_SHA1 hash/sha1/openssl.*)
105+
elseif(USE_SHA1 STREQUAL "CommonCrypto")
106+
file(GLOB SRC_SHA1 hash/sha1/common_crypto.*)
107+
elseif(USE_SHA1 STREQUAL "mbedTLS")
108+
file(GLOB SRC_SHA1 hash/sha1/mbedtls.*)
109+
elseif(USE_SHA1 STREQUAL "Win32")
110+
file(GLOB SRC_SHA1 hash/sha1/win32.*)
111+
elseif(USE_SHA1 STREQUAL "Generic")
112+
file(GLOB SRC_SHA1 hash/sha1/generic.*)
113+
endif()
114+
list(APPEND SRC_SHA1 "hash/sha1.h")
100115
target_sources(git2internal PRIVATE ${SRC_SHA1})
101116

102117
# Optional external dependency: ntlmclient

0 commit comments

Comments
 (0)