Commit a7e36d3d9c473647f141b24d398a98171744ceee

Carlos Martín Nieto 2018-01-08T13:30:04

Merge pull request #4468 from libgit2/cmn/openssl-pc Make sure to include 'openssl' as a dep when building statically with SHA1DC

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c8389c2..b03b96a 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -184,6 +184,7 @@ IF (USE_HTTPS)
 		LIST(APPEND LIBGIT2_INCLUDES ${OPENSSL_INCLUDE_DIR})
 		LIST(APPEND LIBGIT2_LIBS ${OPENSSL_LIBRARIES})
 		LIST(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS})
+		LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
 	ELSEIF (HTTPS_BACKEND STREQUAL "WinHTTP")
 		# WinHTTP setup was handled in the WinHTTP-specific block above
 	ELSE()
@@ -210,7 +211,7 @@ IF(SHA1_BACKEND STREQUAL "OpenSSL")
 	IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
 		LIST(APPEND LIBGIT2_PC_LIBS "-lssl")
 	ELSE()
-		SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} openssl")
+		LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
 	ENDIF()
 ELSEIF(SHA1_BACKEND STREQUAL "CollisionDetection")
 	ADD_FEATURE_INFO(SHA ON "using CollisionDetection")
@@ -265,7 +266,7 @@ IF(NOT USE_BUNDLED_ZLIB)
 			LIST(APPEND LIBGIT2_LIBS "z")
 			LIST(APPEND LIBGIT2_PC_LIBS "-lz")
 		ELSE()
-			SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} zlib")
+			LIST(APPEND LIBGIT2_PC_REQUIRES "zlib")
 		ENDIF()
 		ADD_FEATURE_INFO(zlib ON "using system zlib")
 	ELSE()
@@ -439,6 +440,9 @@ IF (SONAME)
 		SET_TARGET_PROPERTIES(git2 PROPERTIES PREFIX "${LIBGIT2_PREFIX}")
 	ENDIF()
 ENDIF()
+
+LIST(REMOVE_DUPLICATES LIBGIT2_PC_REQUIRES)
+STRING(REPLACE ";" " " LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES}")
 STRING(REPLACE ";" " " LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS}")
 CONFIGURE_FILE(${libgit2_SOURCE_DIR}/libgit2.pc.in ${libgit2_BINARY_DIR}/libgit2.pc @ONLY)