# FindPackageMessage

This module provides a command for printing find result messages and is intended for use in Find Modules implementing `find_package(<PackageName>)` calls.

Load this module in a CMake find module with:

`FindFoo.cmake`

    include(FindPackageMessage)

## Commands

This module provides the following command:

find_package_message

  Prints a message once for each unique find result to inform the user which package was found and where:

      find_package_message(<PackageName> <message> <details>)

  `<PackageName>`

    The name of the package (for example, as used in the `Find<PackageName>.cmake` module filename).

  `<message>`

    The message string to display.

  `<details>`

    A unique identifier for tracking message display. The `<message>` is printed only once per distinct `<details>` value. If `<details>` string changes in a subsequent configuration phase, the message will be displayed again.

  If `find_package()` was called with the `QUIET` option, the `<message>` is not printed.

## Examples

Printing a result message in a custom find module:

`FindFoo.cmake`

    find_library(Foo_LIBRARY foo)
    find_path(Foo_INCLUDE_DIR foo.h)

    include(FindPackageMessage)

    if(Foo_LIBRARY AND Foo_INCLUDE_DIR)
      find_package_message(
        Foo
        "Found Foo: ${Foo_LIBRARY}"
        "[${Foo_LIBRARY}][${Foo_INCLUDE_DIR}]"
      )
    else()
      message(STATUS "Could NOT find Foo")
    endif()

When writing standard find modules, use the `FindPackageHandleStandardArgs` module and its `find_package_handle_standard_args()` command which automatically prints the find result message based on whether the package was found:

`FindFoo.cmake`

    # ...

    include(FindPackageHandleStandardArgs)

    find_package_handle_standard_args(
      Foo
      REQUIRED_VARS Foo_LIBRARY Foo_INCLUDE_DIR
    )