More control on `find_package` version checks
Right now the producer project has full decision authority of what versions the caller of find_package(CONFIG)
requests. For example, let's say the producer project sets COMPATIBILITY SameMajorVersion
, but we want to check for >=2.3.0
, but 2.1.0
is installed. You cannot add find_package(2.3.0)
because the minimum version (range or not) is not being processed 1
Even if we change this logic, this change will not take effect until the packaging OS update the CMake version.
I have a suggestion for this to add an additional VERSIONS
multi-variable kwarg that will allow a pythonic version syntax:
- All conditions are
AND
-ed together soVERSIONS >=2.2.0 !=2.2.1
is effectivelyVERSION_GREATER_EQUAL 2.2.0 AND NOT VERSION_EQUAL 2.2.1
- When both
VERSIONS
and non-tagged version is passed either:- Error as undefined
- Pass the non-tagged to the
<Package>Version.cmake
andAND
the result with the conditions fromVERSIONS
- If no operator is provided, use the version specified there in
<Package>Version.cmake
either as:- Forbid any operator syntax and allow only 1 version to be specified (the current logic)
- Forbid any operator syntax, but allow multiple versions to be specified which are tried one at a time as an effective
OR
- Allow both operator syntax and multiple non-operator version with an effective
OR
between the non-operator versions and an effectiveAND
between everything else
Edited by Cristian Le