Search⌘ K
AI Features

Generating Package Version Files

Explore how to generate package version files in CMake using the CMakePackageConfigHelpers module. Understand maintaining backward compatibility and specifying version compatibility levels to help developers find and use correct package versions during project builds.

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 ...