[cmake-developers] Improving the version selection behavior of EXACT

Matthew Woehlke mw_triad at users.sourceforge.net
Mon Jan 12 11:40:19 EST 2015


On 2015-01-09 14:18, Rolf Eike Beer wrote:
> Matthew Woehlke wrote:
>> On 2014-10-03 03:35, Rolf Eike Beer wrote:
>>> find_package(foo 2.0 EXACT) means EXACT, i.e. only "2.0" is allowed.. In
>>> most cases this behavior is not the one that one would expect or need.
>>> Most people would instead allow any 2.0.x version to match. This sort of
>>> selection is currently impossible without additional effort in every
>>> Find*.cmake that is used.
>>
>> This is probably a bit late, but did anyone think of using "MATCHES" to
>> say "all provided components match exactly and the rest can be whatever"?
> 
> I bet everybody will get it wrong.
> 
> Ok, this is "version 2.1 and any of it's patch versions", if _I_ got it right:
> 
> if (VER MATCHES "^2\\.1(\\..*|[^0-9].*)?$")
> 
> So this should match "2.1", "2.1a", "2.1.1", but not "2.10". What combination 
> of stuff did I miss?

...except I was talking about a new mode for find_package (*not*
necessarily a regex). IOW:

  find_package(Foo 2.1 MATCHES)

...finds Foo 2.1, 2.1.0, 2.1.beta, etc., but not 2.0, 2.0.1, 2.2, etc.

(In if(), if available at all (which maybe it needs to be), it would be
spelled VERSION_MATCHES.)

Anyway, your regex is overcomplicated; I'd think it would be just
'^2[.]1([.]|$)'. (I'd be a little hesitant to allow '2.1a' to match
'2.1'... is that '2.1 alpha' or 'release "a" after 2.1'? Or the release
following '2.19' because someone is using hex version numbers? I'm not
entirely sure that *any* of those should "match" 2.1, and certainly at
most only one should match.)

-- 
Matthew



More information about the cmake-developers mailing list