From 474c8cf8329c96782942763712d372534e862f32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Wed, 23 Oct 2013 22:49:52 +0200 Subject: [PATCH] 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. --- CMakeLists.txt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94418f85b..6010b63a6 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()