...

/

Generating Package Version Files

Generating Package Version Files

Let's learn about utility modules that generate the package's version files.

Interestingly, CMakePackageConfigHelpers also provides a helper command to generate package's version files. Let's take a look.

As our package grows, it will slowly gain new features, old ones will be marked as deprecated, and eventually be removed. It's important to keep track of these modifications in a changelog that's available to developers that use our package. When a specific feature is needed, a developer can find the lowest version that supports it and use it as an argument to find_package(), like so:

find_package(Calc 1.2.3 REQUIRED)

CMake will then search the config-file for Calc and check if a version file named <config-file>-version.cmake or <config-file>Version.cmake is present in the same directory, that is, CalcConfigVersion.cmake. Next, this file will be read for its version information and the compatibility it provides with other versions. For example, we may not have version 1.2.3 installed as required, but we may have 1.3.5, ...