FindPNG — CMake 4.4.3-dirty Documentation

# FindPNG

Finds libpng, the official reference library for the PNG image format:

    find_package(PNG [<version>] [...])

Note

The PNG library depends on the ZLib compression library, which must be found for this module to succeed.

## Imported Targets

This module provides the following Imported Targets:

`PNG::PNG`

  Added in version 3.5.

  Target encapsulating the libpng library usage requirements, available if libpng is found.

## Result Variables

This module defines the following variables:

`PNG_FOUND`

  Boolean indicating whether the (requested version of) PNG library was found.

`PNG_VERSION`

  Added in version 4.2.

  The version of the PNG library found.

`PNG_INCLUDE_DIRS`

  Directory containing the PNG headers (e.g., `png.h`).

`PNG_LIBRARIES`

  PNG libraries required for linking.

`PNG_DEFINITIONS`

  Compile definitions for using PNG, if any. They can be added with `target_compile_definitions()` command when not using the `PNG::PNG` imported target.

## Deprecated Variables

The following variables may also be set for backward compatibility:

`PNG_LIBRARY`

  Deprecated since version 3.0: Use the `PNG::PNG` imported target.

  Path to the PNG library.

`PNG_INCLUDE_DIR`

  Deprecated since version 3.0: Use the `PNG::PNG` imported target.

  Directory containing the PNG headers (same as `PNG_INCLUDE_DIRS`).

`PNG_VERSION_STRING`

  Deprecated since version 4.2: Superseded by the `PNG_VERSION`.

  The version of the PNG library found.

## Examples

Finding PNG library and using it in a project:

    find_package(PNG)
    target_link_libraries(project_target PRIVATE PNG::PNG)