Commit 474c8cf8329c96782942763712d372534e862f32

Carlos Martín Nieto 2013-10-23T22:49:52

Really fix the pc file It turns out that variables have function scope by default. Let's really set -liconv and add a few libraries that were forgotten in the previous commit. We also need to special-case OSX, as they ship zlib but do not provide a pkg-config file for it.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 94418f8..6010b63 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -70,14 +70,16 @@ FUNCTION(TARGET_OS_LIBRARIES target)
 		TARGET_LINK_LIBRARIES(${target} ws2_32)
 	ELSEIF(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
 		TARGET_LINK_LIBRARIES(${target} socket nsl)
+		SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lsocket -lnsl" PARENT_SCOPE)
 	ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
 		TARGET_LINK_LIBRARIES(${target} rt)
+		SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lrt" PARENT_SCOPE)
 	ENDIF()
 
 	IF(USE_ICONV)
 		TARGET_LINK_LIBRARIES(${target} iconv)
 		ADD_DEFINITIONS(-DGIT_USE_ICONV)
-		SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -liconv")
+		SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -liconv" PARENT_SCOPE)
 	ENDIF()
 
 	IF(THREADSAFE)
@@ -166,7 +168,11 @@ FIND_PACKAGE(ZLIB QUIET)
 IF (ZLIB_FOUND)
 	INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
 	LINK_LIBRARIES(${ZLIB_LIBRARIES})
-	SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} zlib")
+	IF(APPLE)
+		SET(LIBGIT2_PC_LIBS "${LIBGIT2_PC_LIBS} -lz")
+	ELSE()
+		SET(LIBGIT2_PC_REQUIRES "${LIBGIT2_PC_REQUIRES} zlib")
+	ENDIF()
 	# Fake the message CMake would have shown
 	MESSAGE("-- Found zlib: ${ZLIB_LIBRARY}")
 ELSE()