1 --- a/Modules/FindZLIB.cmake
2 +++ b/Modules/FindZLIB.cmake
3 @@ -117,10 +117,13 @@ else()
4 set(ZLIB_NAMES_DEBUG zd zlibd zdlld zlibd1 zlib1d zlibstaticd zlibwapid zlibvcd zlibstatd)
7 -# Try each search configuration.
8 -foreach(search ${_ZLIB_SEARCHES})
9 - find_path(ZLIB_INCLUDE_DIR NAMES zlib.h ${${search}} PATH_SUFFIXES include)
12 + find_package(PkgConfig QUIET)
13 + pkg_search_module(PC_zlib zlib)
16 +find_path(ZLIB_INCLUDE_DIR zlib.h HINTS ${PC_zlib_INCLUDEDIR} ${PC_zlib_INCLUDE_DIRS})
17 +find_library(ZLIB_LIBRARY NAMES z HINTS ${PC_zlib_LIBDIR} ${PC_zlib_LIBRARY_DIRS})
19 # Allow ZLIB_LIBRARY to be set manually, as the location of the zlib library