Merge pull request #4678 from staticfloat/sf/mbedtls_linkage Link `mbedTLS` libraries in when `SHA1_BACKEND` == "mbedTLS"
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
diff --git a/.travis.yml b/.travis.yml
index 686041b..61edba1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -58,12 +58,12 @@ matrix:
- compiler: gcc
env:
MBEDTLS=1
- OPTIONS="-DTHREADSAFE=ON -DCMAKE_BUILD_TYPE=Release -DUSE_HTTPS=mbedTLS -DMBEDTLS_ROOT_DIR=../deps/mbedtls"
+ OPTIONS="-DTHREADSAFE=ON -DCMAKE_BUILD_TYPE=Release -DUSE_HTTPS=mbedTLS -DSHA1_BACKEND=mbedTLS -DMBEDTLS_ROOT_DIR=../deps/mbedtls"
os: linux
- compiler: gcc
env:
MBEDTLS=1
- OPTIONS="-DTHREADSAFE=OFF -DBUILD_EXAMPLES=ON -DUSE_HTTPS=mbedTLS -DMBEDTLS_ROOT_DIR=../deps/mbedtls"
+ OPTIONS="-DTHREADSAFE=OFF -DBUILD_EXAMPLES=ON -DUSE_HTTPS=mbedTLS -DSHA1_BACKEND=mbedTLS -DMBEDTLS_ROOT_DIR=../deps/mbedtls"
os: linux
allow_failures:
- env: COVERITY=1
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2b82bb3..2deed5f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -284,8 +284,13 @@ ELSEIF(SHA1_BACKEND STREQUAL "CommonCrypto")
ELSEIF (SHA1_BACKEND STREQUAL "mbedTLS")
ADD_FEATURE_INFO(SHA ON "using mbedTLS")
SET(GIT_SHA1_MBEDTLS 1)
- FILE(GLOB SRC_SHA1 src/hash/hash_mbedtls.c)
- LIST(APPEND LIBGIT2_PC_REQUIRES "mbedtls")
+ FILE(GLOB SRC_SHA1 hash/hash_mbedtls.c)
+ LIST(APPEND LIBGIT2_INCLUDES ${MBEDTLS_INCLUDE_DIR})
+ LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
+ # mbedTLS has no pkgconfig file, hence we can't require it
+ # https://github.com/ARMmbed/mbedtls/issues/228
+ # For now, pass its link flags as our own
+ LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
ELSE()
MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend ${SHA1_BACKEND}")
ENDIF()