# FindZLIB

Finds the native zlib data compression library.

## Imported Targets

This module provides the following Imported Targets:

`ZLIB::ZLIB`

  Added in version 3.1.

  Target that encapsulates the zlib usage requirements. It is available only when zlib is found.

## Result Variables

This module defines the following variables:

`ZLIB_INCLUDE_DIRS`

  Include directories containing `zlib.h` and other headers needed to use zlib.

`ZLIB_LIBRARIES`

  List of libraries needed to link to zlib.

  Changed in version 3.4: Debug and Release library variants can be now found separately.

`ZLIB_FOUND`

  True if zlib is found.

`ZLIB_VERSION`

  Added in version 3.26.

  The version of zlib found.

## 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

This module accepts the following variables:

`ZLIB_ROOT`

  A user may set this variable to a zlib installation root to help locate zlib in custom installation paths.

`ZLIB_USE_STATIC_LIBS`

  Added in version 3.24.

  Set this variable to `ON` before calling `find_package(ZLIB)` to look for static libraries. Default is `OFF`.

## Examples

Finding zlib and linking it to a project target:

    find_package(ZLIB)
    target_link_libraries(project_target PRIVATE ZLIB::ZLIB)