# FindSubversion

Finds a Subversion command-line client executable (`svn`) and provides commands for extracting information from a Subversion working copy:

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

## Result Variables

This module defines the following variables:

`Subversion_FOUND`

  Boolean indicating whether (the requested version of) Subversion command-line client is found. For backward compatibility, the `SUBVERSION_FOUND` variable is also set to the same value.

`Subversion_VERSION_SVN`

  Version of the `svn` command-line client found.

## Cache Variables

The following cache variables may also be set:

`Subversion_SVN_EXECUTABLE`

  Path to the `svn` command-line client.

## Commands

This module provides the following commands if the Subversion command-line client is found:

Subversion_WC_INFO

  Extracts information from a Subversion working copy located at a specified directory:

      Subversion_WC_INFO(<dir> <var-prefix> [IGNORE_SVN_FAILURE])

  This command defines the following variables if running Subversion's `info` subcommand on `<dir>` succeeds; otherwise a `SEND_ERROR` message is generated:

  `<var-prefix>_WC_URL`

    URL of the repository (at `<dir>`).

  `<var-prefix>_WC_ROOT`

    Root URL of the repository.

  `<var-prefix>_WC_REVISION`

    Current revision.

  `<var-prefix>_WC_LAST_CHANGED_AUTHOR`

    Author of last commit.

  `<var-prefix>_WC_LAST_CHANGED_DATE`

    Date of last commit.

  `<var-prefix>_WC_LAST_CHANGED_REV`

    Revision of last commit.

  `<var-prefix>_WC_INFO`

    Output of the command `svn info <dir>`

  The options are:

  `IGNORE_SVN_FAILURE`

    Added in version 3.13.

    When specified, errors from Subversion operation will not trigger a `SEND_ERROR` message. In case of an error, the `<var-prefix>_*` variables remain undefined.

Subversion_WC_LOG

  Retrieves the log message of the base revision of a Subversion working copy at a given location:

      Subversion_WC_LOG(<dir> <var-prefix>)

  This command defines the following variable if running Subversion's `log` subcommand on `<dir>` succeeds; otherwise a `SEND_ERROR` message is generated:

  `<var-prefix>_LAST_CHANGED_LOG`

    Last log of the base revision of a Subversion working copy located at `<dir>`.

## Examples

### Examples: Finding Subversion

Finding Subversion:

    find_package(Subversion)

Or, finding Subversion and specifying a minimum required version:

    find_package(Subversion 1.4)

Or, finding Subversion and making it required (if not found, processing stops with an error message):

    find_package(Subversion REQUIRED)

### Example: Using Subversion

Finding Subversion and retrieving information about the current project's working copy:

    find_package(Subversion)
    if(Subversion_FOUND)
      Subversion_WC_INFO(${PROJECT_SOURCE_DIR} Project)
      message("Current revision is ${Project_WC_REVISION}")
      Subversion_WC_LOG(${PROJECT_SOURCE_DIR} Project)
      message("Last changed log is ${Project_LAST_CHANGED_LOG}")
    endif()