FindZLIB — CMake 3.27.1 Documentation

# FindZLIB

Find the native ZLIB includes and library.

## IMPORTED Targets

New in version 3.1.

This module defines `IMPORTED` target `ZLIB::ZLIB`, if ZLIB has been found.

## Result Variables

This module defines the following variables:

`ZLIB_INCLUDE_DIRS`

  where to find zlib.h, etc.

`ZLIB_LIBRARIES`

  List of libraries when using zlib.

`ZLIB_FOUND`

  True if zlib found.

`ZLIB_VERSION`

  New in version 3.26: the version of Zlib found.

  See also legacy variable `ZLIB_VERSION_STRING`.

New in version 3.4: Debug and Release variants are found separately.

## Legacy Variables

The following variables are provided for backward compatibility:

`ZLIB_VERSION_MAJOR`

  The major version of zlib.

  Changed in version 3.26: Superseded by `ZLIB_VERSION`.

`ZLIB_VERSION_MINOR`

  The minor version of zlib.

  Changed in version 3.26: Superseded by `ZLIB_VERSION`.

`ZLIB_VERSION_PATCH`

  The patch version of zlib.

  Changed in version 3.26: Superseded by `ZLIB_VERSION`.

`ZLIB_VERSION_TWEAK`

  The tweak version of zlib.

  Changed in version 3.26: Superseded by `ZLIB_VERSION`.

`ZLIB_VERSION_STRING`

  The version of zlib found (x.y.z)

  Changed in version 3.26: Superseded by `ZLIB_VERSION`.

`ZLIB_MAJOR_VERSION`

  The major version of zlib. Superseded by `ZLIB_VERSION_MAJOR`.

`ZLIB_MINOR_VERSION`

  The minor version of zlib. Superseded by `ZLIB_VERSION_MINOR`.

`ZLIB_PATCH_VERSION`

  The patch version of zlib. Superseded by `ZLIB_VERSION_PATCH`.

## Hints

A user may set `ZLIB_ROOT` to a zlib installation root to tell this module where to look.

New in version 3.24: Set `ZLIB_USE_STATIC_LIBS` to `ON` to look for static libraries. Default is `OFF`.