[cmake-developers] Documentation of version comparisons needs updating

Craig Scott craig.scott at crascit.com
Sat Sep 15 23:20:45 EDT 2018


On Sun, Sep 16, 2018 at 6:57 AM Alan W. Irwin <Alan.W.Irwin1234 at gmail.com>
wrote:

> The current (3.12.2) "if" documentation says, e.g.,
>
> if(<variable|string> VERSION_LESS_EQUAL <variable|string>)
> Component-wise integer version number comparison (version format is
> major[.minor[.patch[.tweak]]]).
>
> But what happens if any component of the version string is not an
> integer, e.g.,
>
> cmake version 3.12.20180915-g6f04e
>
> for the latest git version used for the cmake dashboard.  It
> appears from the
>
> CMAKE_CACHE_PATCH_VERSION:INTERNAL=20180915
>
> CMakeCache.txt entry that the string "20180915-g6f04e" is reliably
> converted in that case to the integer 20180915, but does that reliable
> conversion also occur for the "if" VERSION comparisons?  And if so,
> shouldn't the "if" documentation say something about truncation of
> trailing non-integer parts of the version components?
>
> What has lead me to these two questions is I am trying to distinguish
> between the above version and 3.12.2, and since the documentation did
> not acknowledge what would be done when non-integer strings were appended
> to any of the integer components of the version string, I am concerned
> the component integers might be determined in an unreliable way for
> trailing non-integer string cases.
>
>

After checking the code to confirm the behavior, I've put up a merge
request with clarification of the docs. You can find it here:

https://gitlab.kitware.com/cmake/cmake/merge_requests/2393

-- 
Craig Scott
Melbourne, Australia
https://crascit.com

New book released: Professional CMake: A Practical Guide
<https://crascit.com/professional-cmake/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake-developers/attachments/20180916/c0748db4/attachment.html>


More information about the cmake-developers mailing list