This sets up the project version by setting these version variables:


It also generates a cmake package config version file as well.

VERSION <major>.<minor>.<patch>

This is the version to be set.

GENERATE_HEADER <header-name>

This is a header which will be generated with defines for the version number.

PREFIX <identifier>

By default, the upper case of the project name is used as a prefix for the version macros that are defined in the generated header: ${PREFIX}_VERSION_MAJOR, ${PREFIX}_VERSION_MINOR, ${PREFIX}_VERSION_PATCH, and ${PREFIX}_VERSION. The PREFIX option allows overriding the prefix name used for the macros.

PARSE_HEADER <header-name>

Rather than set a version and generate a header, this will parse a header with macros that define the version, and then use those values to set the version for the project.

COMPATIBILITY <compatibility>

This uses the version compatibility specified by cmake version config.

NAME <name>

This is the name to use for the package config version file. By default, this uses the project name, but this parameter can override it.