summaryrefslogtreecommitdiffstats
path: root/tools/cmake/patches/140-zlib.patch
blob: 8b7b7de1b04c0bf9f5a7a4e2e698c27c39062aad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
--- a/Modules/FindZLIB.cmake
+++ b/Modules/FindZLIB.cmake
@@ -117,10 +117,13 @@ else()
   set(ZLIB_NAMES_DEBUG zd zlibd zdlld zlibd1 zlib1d zlibstaticd zlibwapid zlibvcd zlibstatd)
 endif()
 
-# Try each search configuration.
-foreach(search ${_ZLIB_SEARCHES})
-  find_path(ZLIB_INCLUDE_DIR NAMES zlib.h ${${search}} PATH_SUFFIXES include)
-endforeach()
+if(UNIX)
+  find_package(PkgConfig QUIET)
+  pkg_search_module(PC_zlib zlib)
+endif()
+
+find_path(ZLIB_INCLUDE_DIR zlib.h HINTS ${PC_zlib_INCLUDEDIR} ${PC_zlib_INCLUDE_DIRS})
+find_library(ZLIB_LIBRARY NAMES z HINTS ${PC_zlib_LIBDIR} ${PC_zlib_LIBRARY_DIRS})
 
 # Allow ZLIB_LIBRARY to be set manually, as the location of the zlib library
 if(NOT ZLIB_LIBRARY)