find_package(PkgConfig) pkg_check_modules(PC_ZLIB zlib) find_path(ZLIB_INCLUDE_DIRS NAMES zlib.h HINTS ${PC_ZLIB_INCLUDEDIR} ${PC_ZLIB_INCLUDE_DIRS} ) find_library(ZLIB_LIBRARIES NAMES z HINTS ${PC_ZLIB_LIBDIR} ${PC_ZLIB_LIBRARY_DIRS} ) #message("ZLIB_LIBRARIES=${ZLIB_LIBRARIES} ZLIB_INCLUDE_DIRS=${ZLIB_INCLUDE_DIRS} PC_ZLIB_VERSION=${PC_ZLIB_VERSION}") if(ZLIB_INCLUDE_DIRS AND ZLIB_LIBRARIES) set(ZLIB_FOUND TRUE) set(ZLIB_LIBRARY ${ZLIB_LIBRARIES}) set(ZLIB_INCLUDE_DIR ${ZLIB_INCLUDE_DIRS}) set(ZLIB_VERSION ${PC_ZLIB_VERSION}) endif() include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(zlib FOUND_VAR ZLIB_FOUND VERSION_VAR ZLIB_VERSION REQUIRED_VARS ZLIB_INCLUDE_DIRS ZLIB_INCLUDE_DIR ZLIB_LIBRARIES ZLIB_LIBRARY) mark_as_advanced(ZLIB_LIBRARIES ZLIB_LIBRARY ZLIB_INCLUDE_DIRS ZLIB_INCLUDE_DIR ZLIB_FOUND ZLIB_VERSION)