We still need to update pkgconfig variables when zlib is unbundled (#5079).
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c23e019..2469962 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -327,6 +327,11 @@ IF(NOT USE_BUNDLED_ZLIB)
IF(ZLIB_FOUND)
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${ZLIB_INCLUDE_DIRS})
LIST(APPEND LIBGIT2_LIBS ${ZLIB_LIBRARIES})
+ IF(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ LIST(APPEND LIBGIT2_PC_LIBS "-lz")
+ ELSE()
+ LIST(APPEND LIBGIT2_PC_REQUIRES "zlib")
+ ENDIF()
ADD_FEATURE_INFO(zlib ON "using system zlib")
ELSE()
MESSAGE(STATUS "zlib was not found; using bundled 3rd-party sources." )