Since release 3.19 CMake allows to specify a range in find_package() calls:
find_package(Dummy minVersion...maxVersion)
Although currently not much find modules support version ranges one might want to set the upper end to a maximum version the code is compatible with. This can be seen as a safeguard against breaking changes in an unknown future major version.
Let say we have a package “Dummy” whose major versions 1 and 2 are known to work with our own code. One might be tempted to specify the version range like the following:
find_package(Dummy 1...2)
This works well with 1.0.0, 1.5.0 or 2.0.0, but will break with 2.0.1 or 2.1.0.
Instead use the following syntax to include major versions 1 and 2:
find_package(Dummy 1...<3)
But why so?
Continue reading “Fun with CMake version ranges”