FindBZip2 — CMake 4.1.4 Documentation

# FindBZip2

Finds the BZip2 data compression library (libbz2):

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

## Imported Targets

This module provides the following Imported Targets:

`BZip2::BZip2`

  Added in version 3.12.

  Target encapsulating the usage requirements of BZip2 library. This target is available only when BZip2 is found.

## Result Variables

This module defines the following variables:

`BZip2_FOUND`

  Boolean indicating whether the BZip2 library is found. For backward compatibility, the `BZIP2_FOUND` variable is also set to the same value.

`BZIP2_INCLUDE_DIRS`

  Added in version 3.12.

  Include directories needed to use BZip2 library.

`BZIP2_LIBRARIES`

  Libraries needed for linking to use BZip2.

`BZIP2_VERSION`

  Added in version 3.26.

  The version of BZip2 found.

## Cache Variables

The following cache variables may also be set:

`BZIP2_INCLUDE_DIR`

  The directory containing the BZip2 headers.

`BZIP2_LIBRARY_RELEASE`

  The path to the BZip2 library for release configurations.

`BZIP2_LIBRARY_DEBUG`

  The path to the BZip2 library for debug configurations.

`BZIP2_NEED_PREFIX`

  Boolean indicating whether BZip2 functions are prefixed with `BZ2_` (e.g., `BZ2_bzCompressInit()`). Versions of BZip2 prior to 1.0.0 used unprefixed function names (e.g., `bzCompressInit()`).

## Legacy Variables

The following variables are provided for backward compatibility:

`BZIP2_VERSION_STRING`

  Changed in version 3.26: Superseded by `BZIP2_VERSION`.

  The version of BZip2 found.

## Examples

Finding BZip2 library and linking it to a project target:

    find_package(BZip2)
    target_link_libraries(project_target PRIVATE BZip2::BZip2)