mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
cmake: standardize HTTPS backend definitions
There were a few oddities around HTTPS provider selection: namely, `GIT_OPENSSL_DYNAMIC` implied `GIT_OPENSSL`, which made a bit of sense, until we added FIPS support. In addition, dynamic OpenSSL for _hashes_ and dynamic OpenSSL for HTTPS was conflated in a few places. Untangle these, and make `GIT_HTTPS_*` the define, for consistency with other feature provider selection.
This commit is contained in:
@@ -48,7 +48,7 @@ if(USE_HTTPS)
|
||||
message(FATAL_ERROR "Cannot use SecureTransport backend, SSLCreateContext not supported")
|
||||
endif()
|
||||
|
||||
set(GIT_SECURE_TRANSPORT 1)
|
||||
set(GIT_HTTPS_SECURETRANSPORT 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
|
||||
list(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
|
||||
@@ -57,7 +57,7 @@ if(USE_HTTPS)
|
||||
message(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
|
||||
endif()
|
||||
|
||||
set(GIT_OPENSSL 1)
|
||||
set(GIT_HTTPS_OPENSSL 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${OPENSSL_LIBRARIES})
|
||||
# Static OpenSSL (lib crypto.a) requires libdl, include it explicitly
|
||||
@@ -102,13 +102,12 @@ if(USE_HTTPS)
|
||||
|
||||
if(CERT_LOCATION)
|
||||
if(NOT EXISTS ${CERT_LOCATION})
|
||||
message(FATAL_ERROR "Cannot use CERT_LOCATION=${CERT_LOCATION} as it doesn't exist")
|
||||
message(FATAL_ERROR "cannot use CERT_LOCATION=${CERT_LOCATION} as it doesn't exist")
|
||||
endif()
|
||||
add_feature_info(CERT_LOCATION ON "using certificates from ${CERT_LOCATION}")
|
||||
add_definitions(-DGIT_DEFAULT_CERT_LOCATION="${CERT_LOCATION}")
|
||||
endif()
|
||||
|
||||
set(GIT_MBEDTLS 1)
|
||||
set(GIT_HTTPS_MBEDTLS 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${MBEDTLS_LIBRARIES})
|
||||
# mbedTLS has no pkgconfig file, hence we can't require it
|
||||
@@ -116,12 +115,12 @@ if(USE_HTTPS)
|
||||
# For now, pass its link flags as our own
|
||||
list(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
|
||||
elseif(USE_HTTPS STREQUAL "Schannel")
|
||||
set(GIT_SCHANNEL 1)
|
||||
set(GIT_HTTPS_SCHANNEL 1)
|
||||
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS "rpcrt4" "crypt32" "ole32")
|
||||
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
|
||||
elseif(USE_HTTPS STREQUAL "WinHTTP")
|
||||
set(GIT_WINHTTP 1)
|
||||
set(GIT_HTTPS_WINHTTP 1)
|
||||
|
||||
# Since MinGW does not come with headers or an import library for winhttp,
|
||||
# we have to include a private header and generate our own import library
|
||||
@@ -137,16 +136,20 @@ if(USE_HTTPS)
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS "rpcrt4" "crypt32" "ole32")
|
||||
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
|
||||
elseif(USE_HTTPS STREQUAL "OpenSSL-Dynamic")
|
||||
set(GIT_OPENSSL 1)
|
||||
set(GIT_OPENSSL_DYNAMIC 1)
|
||||
set(GIT_HTTPS_OPENSSL_DYNAMIC 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS dl)
|
||||
else()
|
||||
message(FATAL_ERROR "unknown HTTPS backend: ${USE_HTTPS}")
|
||||
endif()
|
||||
|
||||
set(GIT_HTTPS 1)
|
||||
add_feature_info(HTTPS GIT_HTTPS "using ${USE_HTTPS}")
|
||||
|
||||
if(USE_HTTPS STREQUAL "mbedTLS" AND CERT_LOCATION)
|
||||
add_feature_info("HTTPS" GIT_HTTPS "using ${USE_HTTPS} (certificate location: ${CERT_LOCATION})")
|
||||
else()
|
||||
add_feature_info("HTTPS" GIT_HTTPS "using ${USE_HTTPS}")
|
||||
endif()
|
||||
else()
|
||||
set(GIT_HTTPS 0)
|
||||
add_feature_info(HTTPS NO "HTTPS support is disabled")
|
||||
add_feature_info("HTTPS" NO "HTTPS support is disabled")
|
||||
endif()
|
||||
|
||||
@@ -34,7 +34,6 @@ elseif(USE_SHA1 STREQUAL "OpenSSL")
|
||||
elseif(USE_SHA1 STREQUAL "OpenSSL-FIPS")
|
||||
set(GIT_SHA1_OPENSSL_FIPS 1)
|
||||
elseif(USE_SHA1 STREQUAL "OpenSSL-Dynamic")
|
||||
set(GIT_SHA1_OPENSSL 1)
|
||||
set(GIT_SHA1_OPENSSL_DYNAMIC 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS dl)
|
||||
elseif(USE_SHA1 STREQUAL "CommonCrypto")
|
||||
@@ -80,7 +79,6 @@ elseif(USE_SHA256 STREQUAL "OpenSSL")
|
||||
elseif(USE_SHA256 STREQUAL "OpenSSL-FIPS")
|
||||
set(GIT_SHA256_OPENSSL_FIPS 1)
|
||||
elseif(USE_SHA256 STREQUAL "OpenSSL-Dynamic")
|
||||
set(GIT_SHA256_OPENSSL 1)
|
||||
set(GIT_SHA256_OPENSSL_DYNAMIC 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS dl)
|
||||
elseif(USE_SHA256 STREQUAL "CommonCrypto")
|
||||
|
||||
Reference in New Issue
Block a user