[CMake] version number parsing
Alan W. Irwin
irwin at beluga.phys.uvic.ca
Fri Sep 21 17:07:24 EDT 2007
On 2007-09-21 14:42-0600 James Bigler wrote:
> James Bigler wrote:
>> Is there an example I could look at to parse out the individual version
>> numbers, once I get this string?
>>
>> STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" version-string ${output})
>>
>> I want to be able to get the three integers out of version-string.
>
> I found some code in FindQt4.cmake:
>
> STRING(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_qt_major_vers
> "${QT_MIN_VERSION}")
> STRING(REGEX REPLACE "^[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_qt_minor_vers
> "${QT_MIN_VERSION}")
> STRING(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_qt_patch_vers
> "${QT_MIN_VERSION}")
>
> According to the documentation, I believe the ()'s create groups that can be
> referenced by "\\1" or "\\2" and such.
Some CMake code that parses 3-part version strings and does numerical
comparisons of them (to determine whether users have the minimum allowed
version, etc.) is contained in
http://plplot.svn.sourceforge.net/viewvc/plplot/trunk/cmake/modules/plplot.cmake?view=log
Look for the macro defined and used in that file called TRANSFORM_VERSION.
Alan
__________________________
Alan W. Irwin
Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).
Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); 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
__________________________
More information about the CMake
mailing list