Discussion:
[cmake-developers] Documentation of version comparisons needs updating
Alan W. Irwin
2018-09-15 22:55:48 UTC
Permalink
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.

Alan
__________________________
Alan W. Irwin

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
--
Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers
Craig Scott
2018-09-16 03:20:45 UTC
Permalink
Post by Alan W. Irwin
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/>
Loading...