FindLibXml2 — CMake 4.1.4 Documentation

# FindLibXml2

Finds the XML processing library (libxml2).

## Imported Targets

This module provides the following Imported Targets:

`LibXml2::LibXml2`

  Added in version 3.12.

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

`LibXml2::xmllint`

  Added in version 3.17.

  Target encapsulating the xmllint command-line executable, available only if xmllint executable is found.

## Result Variables

This module defines the following variables:

`LibXml2_FOUND`

  Boolean indicating whether the libxml2 library is found.

`LIBXML2_INCLUDE_DIRS`

  Include directories needed to use the libxml2 library.

`LIBXML2_LIBRARIES`

  Libraries needed to link against to use the libxml2 library.

`LIBXML2_DEFINITIONS`

  The compiler switches required for using libxml2.

`LIBXML2_VERSION_STRING`

  The version of the libxml2 found.

## Cache Variables

The following cache variables may also be set:

`LIBXML2_INCLUDE_DIR`

  The include directory containing libxml2 headers.

`LIBXML2_LIBRARY`

  The path to the libxml2 library.

`LIBXML2_XMLLINT_EXECUTABLE`

  The path to the XML checking tool `xmllint` coming with libxml2.

## Examples

Finding the libxml2 library and linking it to a project target:

    find_package(LibXml2)
    target_link_libraries(project_target PRIVATE LibXml2::LibXml2)