[CMake] COMPARE_VERSION_STRINGS

Gonzalo Garramuño ggarra at advancedsl.com.ar
Tue Sep 25 22:56:00 EDT 2007


James Bigler wrote:
> I wrote up a page on the wiki about a new macro I wrote that allows you 
> compare version strings directly rather than converting them to a single 
> number for comparisons.
> 
> http://www.cmake.org/Wiki/CMakeCompareVersionStrings
> 
> You can compare versions with any number of dot versions.  If version 
> strings have different numbers of dot versions, the shorter version is 
> padded with zeros.  This allows you to properly compare number such as 
> 0.99 and 0.99.1.
> 
> Take a look and let me know what you think.  I think this could be a 
> fairly useful macro.
> 

Looks cool.  I had to write something like that myself for my own code, 
so what you did is appreciated.

If you wanted to make it more generic, I'd also see if there's a way to 
compare against strings too.

Sometimes, revisions or patch versions are named like:
	0.99a or 0.99-patch2

Also, some programs work in different architectures, so they add the 
platform or architecture to the versioning like:
	0.9-x64
Autodesk maya is one case, for example, of using that scheme.

It would be cool if your macro (or some similarly auxiliary macros) 
allowed a proper comparison of those.

Also, as another comment, I think it is often desirable with some 
libraries to disregard the micro version on == comparisons, so that:
	1.32.1-9  == 1.32
as usually their api does not change.  Currently your macro always will 
return inequality for that.



-- 
Gonzalo Garramuño
ggarra at advancedsl.com.ar

AMD4400 - ASUS48N-E
GeForce7300GT
Kubuntu Edgy


More information about the CMake mailing list