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

Rolf Eike Beer eike at sf-mail.de
Fri Oct 3 14:48:27 EDT 2014


Am Freitag, 3. Oktober 2014, 14:34:38 schrieb Brad King:
> On 10/03/2014 12:47 PM, Rolf Eike Beer wrote:
> > +          # give an exact match if the first ${NAME}_FIND_VERSION_COUNT
> > components of the version string match +          # this constructs the
> > equivalent of "(([^.]\\.){${${_NAME}_FIND_VERSION_COUNT}})" +         
> > unset(_VERSION_REGEX)
> > +          # foreach(RANGE) doesn't like it if stop is greater start
> > +          if (${${_NAME}_FIND_VERSION_COUNT} GREATER 1)
> > +            foreach (_NUM RANGE 2 ${${_NAME}_FIND_VERSION_COUNT})
> > +              set(_VERSION_REGEX "${_VERSION_REGEX}[^.]*\\.")
> > +            endforeach ()
> > +          endif ()
> 
> Since _FIND_VERSION_COUNT is always [0-4], I think a hand-coded lookup
> table may be simpler and faster.

Yes.

> > +          string(REGEX REPLACE "^(${_VERSION_REGEX}[^.]*)\\..*" "\\1"
> > _VERSION_HEAD "${VERSION}")
> Perhaps use something like
> 
>  if(VERSION MATCHES "^(${_VERSION_REGEX}[^.]*)\\..*")
>    set(_VERSION_HEAD "${CMAKE_MATCH_1}")
>  else()
>    message(... bad VERSION in call to fphsa...)
>  endif()
> 
> in case something fails to match for some reason.

I counted the number of dots before, so there must be a match.

Eike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20141003/e6a77078/attachment-0002.sig>


More information about the cmake-developers mailing list