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

2015-01-12 Thread Matthew Woehlke
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

-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers


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

2015-01-12 Thread Ben Boeckel
On Mon, Jan 12, 2015 at 11:40:19 -0500, Matthew Woehlke wrote:
 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'?

Depends on whether it's a normal project or OpenSSL or tzdata :) .

--Ben
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers


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

2015-01-09 Thread Matthew Woehlke
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?

-- 
Matthew

-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers


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

2015-01-09 Thread Rolf Eike Beer
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?

Eike
-- 

signature.asc
Description: This is a digitally signed message part.
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers

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

2015-01-09 Thread Ben Boeckel
On Fri, Jan 09, 2015 at 20:18:25 +0100, 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?

What about VERSION_RANGE 2.1 2.2 which is interpreted as a half-open
range? Should be easier with:

NOT ver VERSION_LESS low AND ver VERSION_LESS high

--Ben
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers


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

2014-10-07 Thread Brad King
On 10/06/2014 04:04 PM, Rolf Eike Beer wrote:
 Topic FPHSA_exact_version pushed to next.

Thanks.  The impl looks okay to me.  Please look at extending
the FindPackageTest with a case to cover this.  It already has
at least one case for FPHSA.  Alternatively you could add cases
to RunCMake.find_package if that proves easier.

Thanks,
-Brad

-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers


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

2014-10-06 Thread Rolf Eike Beer
Brad King wrote:
 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.

Topic FPHSA_exact_version pushed to next.

Eike
-- 

signature.asc
Description: This is a digitally signed message part.
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers

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

2014-10-03 Thread David Cole via cmake-developers
How about IN_RANGE and/or IN_SET options?

Where IN_RANGE takes two version numbers (low and high) and does the
equivalent of:

if ( (NOT ver VERSION_LESS low) AND (ver VERSION_LESS high) )

Or possibly even IN_RANGES with multiple ranges...

And IN_SET takes a list of explicit version numbers and looks for
exact matches among multiple choices...?


It's all pie in the sky until you reach up and pull one down. ;-)

D



On Fri, Oct 3, 2014 at 3:35 AM, Rolf Eike Beer e...@sf-mail.de 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.

 I came over this when I tried converting FindLua5[01].cmake to use
 FindLua.cmake, but I can't do find_package(Lua 5.0 EXACT) in there because
 e.g. 5.0.1 would not be accepted then, and I neither can do find_package(Lua
 5.0) because that may return e.g. 5.2 instead.

 Since we can't change this because of the usual backward compatibility
 concerns I think we should introduce a new version mode, e.g. EXACT_OR_MINOR
 (or any other naming you find more appropiate).

 In case this is aggreed on I would try to create a patch ASAP to be able to
 still land it in 3.1.

 Opinions?

 Eike
 --

 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:
 http://public.kitware.com/mailman/listinfo/cmake-developers
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers


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

2014-10-03 Thread Brad King
On 10/03/2014 03:35 AM, 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.

Yes.  The EXACT should refer to exactly matching whatever components are
given by the caller.  Following components should still be free to vary.
If the caller wants them to be exact too then they should be specified.

 This sort of selection is currently impossible without additional effort
 in every Find*.cmake that is used.

Is that because of FPHSA's implementation?

 Since we can't change this because of the usual backward compatibility 
 concerns I think we should introduce a new version mode, e.g. EXACT_OR_MINOR 
 (or any other naming you find more appropiate).
 
 In case this is aggreed on I would try to create a patch ASAP to be able to 
 still land it in 3.1.

I'd rather not introduce a new API in an important command like find_package
immediately before a release.  However, the documentation of find_package
has always said that it is up to the Find module (or package version file
in Config mode) for each package to decide whether a version matches.

I think FPHSA could be changed to implement the expected behavior for
EXACT discussed above.  The current implementation effectively adds
unlimited implicit .0.0.0 to the caller's components as part of
if(VERSION_EQUAL).  Instead FPHSA could truncate the available version
to match the number of components provided by the caller's version
request before using if(VERSION_EQUAL).

-Brad

-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers


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

2014-10-03 Thread Rolf Eike Beer
Am Freitag, 3. Oktober 2014, 08:41:47 schrieb Brad King:
 On 10/03/2014 03:35 AM, 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.
 
 Yes.  The EXACT should refer to exactly matching whatever components are
 given by the caller.  Following components should still be free to vary.
 If the caller wants them to be exact too then they should be specified.
 
  This sort of selection is currently impossible without additional effort
  in every Find*.cmake that is used.
 
 Is that because of FPHSA's implementation?

I think that is the main reason.

  Since we can't change this because of the usual backward compatibility
  concerns I think we should introduce a new version mode, e.g.
  EXACT_OR_MINOR (or any other naming you find more appropiate).
  
  In case this is aggreed on I would try to create a patch ASAP to be able
  to
  still land it in 3.1.
 
 I'd rather not introduce a new API in an important command like find_package
 immediately before a release.  However, the documentation of find_package
 has always said that it is up to the Find module (or package version file
 in Config mode) for each package to decide whether a version matches.
 
 I think FPHSA could be changed to implement the expected behavior for
 EXACT discussed above.  The current implementation effectively adds
 unlimited implicit .0.0.0 to the caller's components as part of
 if(VERSION_EQUAL).  Instead FPHSA could truncate the available version
 to match the number of components provided by the caller's version
 request before using if(VERSION_EQUAL).

If it is acceptable to change FPHSA in that way I can just go for it.

Eike

signature.asc
Description: This is a digitally signed message part.
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers

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

2014-10-03 Thread Brad King
On 10/03/2014 08:43 AM, Rolf Eike Beer wrote:
 I think FPHSA could be changed to implement the expected behavior for
 EXACT
 
 If it is acceptable to change FPHSA in that way I can just go for it.

Yes, please try it.

Thanks,
-Brad

-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers


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

2014-10-03 Thread Rolf Eike Beer
Brad King wrote:
 On 10/03/2014 08:43 AM, Rolf Eike Beer wrote:
  I think FPHSA could be changed to implement the expected behavior for
  EXACT
  
  If it is acceptable to change FPHSA in that way I can just go for it.
 
 Yes, please try it.

It looks like this line is the culprit:

  if (NOT ${${_NAME}_FIND_VERSION} VERSION_EQUAL ${VERSION})

I can solve this in CMake language, but the question is again if it may be 
worth solving in the command itself? Meanwhile I'll prepare an implementation 
in CMake code, we can replace that with anything better anytime later.

Eike
-- 

signature.asc
Description: This is a digitally signed message part.
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers

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

2014-10-03 Thread Brad King
On 10/03/2014 11:53 AM, Rolf Eike Beer wrote:
 It looks like this line is the culprit:
 
   if (NOT ${${_NAME}_FIND_VERSION} VERSION_EQUAL ${VERSION})
 
 I can solve this in CMake language, but the question is again if it may be 
 worth solving in the command itself? Meanwhile I'll prepare an implementation 
 in CMake code, we can replace that with anything better anytime later.

Yes, I think the command should be fixed to compare only as many
components as are given on both sides, ignoring extra on one side.
However, that will require a policy.

Please fix it in the module by hand for now and look at adding a
policy for this after the 3.1 release.

Thanks,
-Brad

-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers


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

2014-10-03 Thread Rolf Eike Beer
Brad King wrote:
 On 10/03/2014 11:53 AM, Rolf Eike Beer wrote:
  It looks like this line is the culprit:
if (NOT ${${_NAME}_FIND_VERSION} VERSION_EQUAL ${VERSION})
  
  I can solve this in CMake language, but the question is again if it may be
  worth solving in the command itself? Meanwhile I'll prepare an
  implementation in CMake code, we can replace that with anything better
  anytime later.
 Yes, I think the command should be fixed to compare only as many
 components as are given on both sides, ignoring extra on one side.
 However, that will require a policy.
 
 Please fix it in the module by hand for now and look at adding a
 policy for this after the 3.1 release.

Yes, that was my plan. This is what I have now (diff -b for easier review):

diff --git a/Modules/FindPackageHandleStandardArgs.cmake 
b/Modules/FindPackageHandleStandardArgs.cmake
index e8d1dfb..f8c990e 100644
--- a/Modules/FindPackageHandleStandardArgs.cmake
+++ b/Modules/FindPackageHandleStandardArgs.cmake
@@ -290,12 +290,38 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME 
_FIRST_ARG)
 if(VERSION)
 
   if(${_NAME}_FIND_VERSION_EXACT)   # exact version required
+# count the dots in the version string
+string(REGEX REPLACE [^.]  _VERSION_DOTS ${VERSION})
+# add one dot because there is one dot more than there are components
+string(LENGTH ${_VERSION_DOTS}. _VERSION_DOTS)
+if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT)
+  # 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 ()
+  string(REGEX REPLACE ^(${_VERSION_REGEX}[^.]*)\\..* \\1 
_VERSION_HEAD ${VERSION})
+  unset(_VERSION_REGEX)
+  if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD)
+set(VERSION_MSG Found unsuitable version \${VERSION}\, but 
required is exact version \${${_NAME}_FIND_VERSION}\)
+set(VERSION_OK FALSE)
+  else ()
+set(VERSION_MSG (found suitable exact version \${VERSION}\))
+  endif ()
+  unset(_VERSION_HEAD)
+else ()
   if (NOT ${${_NAME}_FIND_VERSION} VERSION_EQUAL ${VERSION})
 set(VERSION_MSG Found unsuitable version \${VERSION}\, but 
required is exact version \${${_NAME}_FIND_VERSION}\)
 set(VERSION_OK FALSE)
   else ()
 set(VERSION_MSG (found suitable exact version \${VERSION}\))
   endif ()
+endif ()
+unset(_VERSION_DOTS)
 
   else() # minimum version specified:
 if (${${_NAME}_FIND_VERSION} VERSION_GREATER ${VERSION})


Eike
-- 

signature.asc
Description: This is a digitally signed message part.
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers

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

2014-10-03 Thread 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.

 +  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.

Thanks,
-Brad

-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers


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

2014-10-03 Thread Rolf Eike Beer
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

signature.asc
Description: This is a digitally signed message part.
-- 

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:
http://public.kitware.com/mailman/listinfo/cmake-developers