From 3b050c47ec301264e5d380cf4e19f0fb7f397d1a Mon Sep 17 00:00:00 2001 From: David Faure Date: Thu, 4 May 2006 21:30:40 +0000 Subject: Factorize the version-number parsing and checking code into a separate macro. Already used by the gpgme version check in kdepim. FindQt4 has similar code, but since it's a fork of a CMake module I'm not sure if I should modify it CCMAIL: kde-buildsystem@kde.org svn path=/trunk/KDE/kdelibs/; revision=537476 --- modules/MacroEnsureVersion.cmake | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 modules/MacroEnsureVersion.cmake (limited to 'modules/MacroEnsureVersion.cmake') diff --git a/modules/MacroEnsureVersion.cmake b/modules/MacroEnsureVersion.cmake new file mode 100644 index 00000000..c2bcc448 --- /dev/null +++ b/modules/MacroEnsureVersion.cmake @@ -0,0 +1,28 @@ +# LGPL-v2, David Faure +# +# This macro compares version numbers of the form "x.y.z" +# MACRO_ENSURE_VERSION( ${FOO_MIN_VERSION} ${FOO_VERSION_FOUND} FOO_TOO_OLD) +# will set FOO_TOO_OLD to true if FOO_VERSION_FOUND < FOO_MIN_VERSION +# +MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) + + message(STATUS "requested_version=${requested_version} found_version=${found_version}") + + # parse the parts of the version strings + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_major_vers "${requested_version}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_minor_vers "${requested_version}") + STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_patch_vers "${requested_version}") + + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" found_major_vers "${found_version}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" found_minor_vers "${found_version}") + STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_patch_vers "${found_version}") + + # compute an overall version number which can be compared at once + MATH(EXPR req_vers_num "${req_major_vers}*10000 + ${req_minor_vers}*100 + ${req_patch_vers}") + MATH(EXPR found_vers_num "${found_major_vers}*10000 + ${found_minor_vers}*100 + ${found_patch_vers}") + + if (found_vers_num LESS req_vers_num) + set( ${var_too_old} TRUE ) + endif (found_vers_num LESS req_vers_num) + +ENDMACRO(MACRO_ENSURE_VERSION) -- cgit v1.2.1 From 35a85527e19dcfbc67bea3774bd6ac0383a2f7ff Mon Sep 17 00:00:00 2001 From: Allen Winter Date: Thu, 11 May 2006 20:44:24 +0000 Subject: remove debugging message. aleXXX said it was ok. svn path=/trunk/KDE/kdelibs/; revision=539852 --- modules/MacroEnsureVersion.cmake | 2 -- 1 file changed, 2 deletions(-) (limited to 'modules/MacroEnsureVersion.cmake') diff --git a/modules/MacroEnsureVersion.cmake b/modules/MacroEnsureVersion.cmake index c2bcc448..89047307 100644 --- a/modules/MacroEnsureVersion.cmake +++ b/modules/MacroEnsureVersion.cmake @@ -6,8 +6,6 @@ # MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) - message(STATUS "requested_version=${requested_version} found_version=${found_version}") - # parse the parts of the version strings STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_major_vers "${requested_version}") STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_minor_vers "${requested_version}") -- cgit v1.2.1 From a98eacc458a303f769590c6af4bfae6920845a51 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Mon, 3 Jul 2006 23:45:27 +0000 Subject: -use positive logic for macro_ensure_version(MIN found RESULT) -> result is true, if the vesion is ok -first try at creating batch files under windows -prepare a libexec install dir -better check for visibility support: only for gcc >= 4.1 if not compiled with the mt allocator Alex svn path=/trunk/KDE/kdelibs/; revision=557782 --- modules/MacroEnsureVersion.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'modules/MacroEnsureVersion.cmake') diff --git a/modules/MacroEnsureVersion.cmake b/modules/MacroEnsureVersion.cmake index 89047307..091152d4 100644 --- a/modules/MacroEnsureVersion.cmake +++ b/modules/MacroEnsureVersion.cmake @@ -1,12 +1,12 @@ # LGPL-v2, David Faure # # This macro compares version numbers of the form "x.y.z" -# MACRO_ENSURE_VERSION( ${FOO_MIN_VERSION} ${FOO_VERSION_FOUND} FOO_TOO_OLD) -# will set FOO_TOO_OLD to true if FOO_VERSION_FOUND < FOO_MIN_VERSION +# MACRO_ENSURE_VERSION( ${FOO_MIN_VERSION} ${FOO_VERSION_FOUND} FOO_VERSION_OK) +# will set FOO_VERSIN_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION # MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) - # parse the parts of the version strings + # parse the parts of the version string STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_major_vers "${requested_version}") STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_minor_vers "${requested_version}") STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_patch_vers "${requested_version}") @@ -20,6 +20,8 @@ MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) MATH(EXPR found_vers_num "${found_major_vers}*10000 + ${found_minor_vers}*100 + ${found_patch_vers}") if (found_vers_num LESS req_vers_num) + set( ${var_too_old} FALSE ) + else (found_vers_num LESS req_vers_num) set( ${var_too_old} TRUE ) endif (found_vers_num LESS req_vers_num) -- cgit v1.2.1 From aa3edadeb55b1ea02f59bdf864d88a1f4f3a5801 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Wed, 16 Aug 2006 17:05:20 +0000 Subject: fix version extraction regexps. svn path=/trunk/KDE/kdelibs/; revision=573563 --- modules/MacroEnsureVersion.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/MacroEnsureVersion.cmake') diff --git a/modules/MacroEnsureVersion.cmake b/modules/MacroEnsureVersion.cmake index 091152d4..ab395819 100644 --- a/modules/MacroEnsureVersion.cmake +++ b/modules/MacroEnsureVersion.cmake @@ -8,11 +8,11 @@ MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) # parse the parts of the version string STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_major_vers "${requested_version}") - STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+" "\\1" req_minor_vers "${requested_version}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" req_minor_vers "${requested_version}") STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_patch_vers "${requested_version}") STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" found_major_vers "${found_version}") - STRING(REGEX REPLACE "[0-9]+\\.([0-9])+\\.[0-9]+.*" "\\1" found_minor_vers "${found_version}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" found_minor_vers "${found_version}") STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_patch_vers "${found_version}") # compute an overall version number which can be compared at once -- cgit v1.2.1 From c778596920e0d5357f216c885e35b4f97d371a23 Mon Sep 17 00:00:00 2001 From: Alexander Neundorf Date: Sat, 9 Sep 2006 10:18:35 +0000 Subject: added copyright notice everywhere. Now they all are BSD-licensed, as copyright holder I inserted everywhere the one who added it to svn (or Kitware if it is an enhanced copy from taken cmake) Some developers committed quite often but were not the ones who added the file, if you feel you have also copyright on the file add your name in the specific file. Copyright holders: CCMAIL: montel@kde.org CCMAIL: toscano.pino@tiscali.it CCMAIL: adymo@kdevelop.org CCMAIL: ranger@befunk.com CCMAIL: zack@kde.org CCMAIL: caslav.ilic@gmx.net CCMAIL: syntheticpp@yahoo.com CCMAIL: js@iidea.pl CCMAIL: michael.larouche@kdemail.net CCMAIL: ossi@kde.org CCMAIL: faure@kde.org Committers, but no files added so that they are not listed as copyright holders: CCMAIL: ch.ehrlicher@gmx.de CCMAIL: winter@kde.org CCMAIL: ralf.habacker@freenet.de CCMAIL: moura@kdewebdev.org CCMAIL: kde-buildsystem@kde.org Alex svn path=/trunk/KDE/kdelibs/; revision=582410 --- modules/MacroEnsureVersion.cmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'modules/MacroEnsureVersion.cmake') diff --git a/modules/MacroEnsureVersion.cmake b/modules/MacroEnsureVersion.cmake index ab395819..3ff1d72f 100644 --- a/modules/MacroEnsureVersion.cmake +++ b/modules/MacroEnsureVersion.cmake @@ -1,9 +1,12 @@ -# LGPL-v2, David Faure -# # This macro compares version numbers of the form "x.y.z" # MACRO_ENSURE_VERSION( ${FOO_MIN_VERSION} ${FOO_VERSION_FOUND} FOO_VERSION_OK) # will set FOO_VERSIN_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION + +# Copyright (c) 2006, David Faure, # +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) # parse the parts of the version string -- cgit v1.2.1 From a42e1a32d04c5598067f69bddc6dc1211724f1dd Mon Sep 17 00:00:00 2001 From: Jakob Petsovits Date: Tue, 26 Sep 2006 16:29:17 +0000 Subject: improve docs (done by Alexander Neundorf on my laptop) svn path=/trunk/KDE/kdelibs/; revision=588684 --- modules/MacroEnsureVersion.cmake | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'modules/MacroEnsureVersion.cmake') diff --git a/modules/MacroEnsureVersion.cmake b/modules/MacroEnsureVersion.cmake index 3ff1d72f..badb50db 100644 --- a/modules/MacroEnsureVersion.cmake +++ b/modules/MacroEnsureVersion.cmake @@ -1,6 +1,10 @@ # This macro compares version numbers of the form "x.y.z" -# MACRO_ENSURE_VERSION( ${FOO_MIN_VERSION} ${FOO_VERSION_FOUND} FOO_VERSION_OK) +# MACRO_ENSURE_VERSION( FOO_MIN_VERSION FOO_VERSION_FOUND FOO_VERSION_OK) # will set FOO_VERSIN_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION +# where both have to be in a 3-part-version format, leading and trailing +# text is ok, e.g. +# MACRO_ENSURE_VERSION( "2.5.31" "flex 2.5.4a" VERSION_OK) +# which means 2.5.31 is required and "flex 2.5.4a" is what was found on the system # Copyright (c) 2006, David Faure, # @@ -13,11 +17,11 @@ MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_major_vers "${requested_version}") STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" req_minor_vers "${requested_version}") STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_patch_vers "${requested_version}") - + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" found_major_vers "${found_version}") STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" found_minor_vers "${found_version}") STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_patch_vers "${found_version}") - + # compute an overall version number which can be compared at once MATH(EXPR req_vers_num "${req_major_vers}*10000 + ${req_minor_vers}*100 + ${req_patch_vers}") MATH(EXPR found_vers_num "${found_major_vers}*10000 + ${found_minor_vers}*100 + ${found_patch_vers}") -- cgit v1.2.1 From 8bd7e5ecf5b27cfcf56e697230f772988955d0d9 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Thu, 28 Sep 2006 12:33:33 +0000 Subject: Necessary to test patch version Otherwise 2.5.4 is inferior to 2.5.31 In this function we calculate it as : 2.5.4: 2*1000+5*100+4 = 2504 2.5.31: 2*1000+5*100+31 = 2531 => it was supperior. Now I test last patch version and adapt it. svn path=/trunk/KDE/kdelibs/; revision=589662 --- modules/MacroEnsureVersion.cmake | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'modules/MacroEnsureVersion.cmake') diff --git a/modules/MacroEnsureVersion.cmake b/modules/MacroEnsureVersion.cmake index badb50db..fee62c7f 100644 --- a/modules/MacroEnsureVersion.cmake +++ b/modules/MacroEnsureVersion.cmake @@ -22,6 +22,11 @@ MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" found_minor_vers "${found_version}") STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_patch_vers "${found_version}") + # Necessary to multiply by 10 otherwise 2.5.4 is inferior to 2.5.31 + if( req_patch_vers GREATER "9" AND found_patch_vers LESS "10") + MATH(EXPR found_patch_vers "${found_patch_vers}*10") + endif(req_patch_vers GREATER "9" AND found_patch_vers LESS "10") + # compute an overall version number which can be compared at once MATH(EXPR req_vers_num "${req_major_vers}*10000 + ${req_minor_vers}*100 + ${req_patch_vers}") MATH(EXPR found_vers_num "${found_major_vers}*10000 + ${found_minor_vers}*100 + ${found_patch_vers}") -- cgit v1.2.1 From 1835e933571cdb11a16e1e3c8c6d946439d21d17 Mon Sep 17 00:00:00 2001 From: Laurent Montel Date: Thu, 28 Sep 2006 13:22:29 +0000 Subject: Revert previous commit I made an error to understand how version label worked. svn path=/trunk/KDE/kdelibs/; revision=589688 --- modules/MacroEnsureVersion.cmake | 5 ----- 1 file changed, 5 deletions(-) (limited to 'modules/MacroEnsureVersion.cmake') diff --git a/modules/MacroEnsureVersion.cmake b/modules/MacroEnsureVersion.cmake index fee62c7f..badb50db 100644 --- a/modules/MacroEnsureVersion.cmake +++ b/modules/MacroEnsureVersion.cmake @@ -22,11 +22,6 @@ MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" found_minor_vers "${found_version}") STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_patch_vers "${found_version}") - # Necessary to multiply by 10 otherwise 2.5.4 is inferior to 2.5.31 - if( req_patch_vers GREATER "9" AND found_patch_vers LESS "10") - MATH(EXPR found_patch_vers "${found_patch_vers}*10") - endif(req_patch_vers GREATER "9" AND found_patch_vers LESS "10") - # compute an overall version number which can be compared at once MATH(EXPR req_vers_num "${req_major_vers}*10000 + ${req_minor_vers}*100 + ${req_patch_vers}") MATH(EXPR found_vers_num "${found_major_vers}*10000 + ${found_minor_vers}*100 + ${found_patch_vers}") -- cgit v1.2.1 From 6b8bf982f6253e457e4a60060bb0acd279164e1b Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 15 Jan 2007 10:55:23 +0000 Subject: Fix parsing of found_version when it starts with letters, like "Flex 2.5.4a". Otherwise it would set found_major_vers = "Flex 2" etc. Report, analysis, and fix by Marc.Schodermayr telemotive.de - thanks! svn path=/trunk/KDE/kdelibs/; revision=623718 --- modules/MacroEnsureVersion.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'modules/MacroEnsureVersion.cmake') diff --git a/modules/MacroEnsureVersion.cmake b/modules/MacroEnsureVersion.cmake index badb50db..9d936ce7 100644 --- a/modules/MacroEnsureVersion.cmake +++ b/modules/MacroEnsureVersion.cmake @@ -18,9 +18,9 @@ MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" req_minor_vers "${requested_version}") STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_patch_vers "${requested_version}") - STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" found_major_vers "${found_version}") - STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" found_minor_vers "${found_version}") - STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_patch_vers "${found_version}") + STRING(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" found_major_vers "${found_version}") + STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" found_minor_vers "${found_version}") + STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_patch_vers "${found_version}") # compute an overall version number which can be compared at once MATH(EXPR req_vers_num "${req_major_vers}*10000 + ${req_minor_vers}*100 + ${req_patch_vers}") -- cgit v1.2.1 From 7187b3101f91daf34441a9903add8d71cd52d4ee Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 19 Mar 2007 13:41:24 +0000 Subject: shared-mime-info related macros by Pino Toscano (thanks!) svn path=/trunk/KDE/kdelibs/; revision=644190 --- modules/MacroEnsureVersion.cmake | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'modules/MacroEnsureVersion.cmake') diff --git a/modules/MacroEnsureVersion.cmake b/modules/MacroEnsureVersion.cmake index 9d936ce7..c6df537a 100644 --- a/modules/MacroEnsureVersion.cmake +++ b/modules/MacroEnsureVersion.cmake @@ -33,3 +33,39 @@ MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) endif (found_vers_num LESS req_vers_num) ENDMACRO(MACRO_ENSURE_VERSION) + + +# This macro compares version numbers of the form "x.y" +# MACRO_ENSURE_VERSION( FOO_MIN_VERSION FOO_VERSION_FOUND FOO_VERSION_OK) +# will set FOO_VERSIN_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION +# where both have to be in a 2-part-version format, leading and trailing +# text is ok, e.g. +# MACRO_ENSURE_VERSION( "0.5" "foo 0.6" VERSION_OK) +# which means 0.5 is required and "foo 0.6" is what was found on the system + +# Copyright (c) 2006, David Faure, +# Copyright (c) 2007, Pino Toscano, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +MACRO(MACRO_ENSURE_VERSION2 requested_version found_version var_too_old) + + # parse the parts of the version string + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+" "\\1" req_major_vers "${requested_version}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)" "\\1" req_minor_vers "${requested_version}") + + STRING(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+.*" "\\1" found_major_vers "${found_version}") + STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+).*" "\\1" found_minor_vers "${found_version}") + + # compute an overall version number which can be compared at once + MATH(EXPR req_vers_num "${req_major_vers}*100 + ${req_minor_vers}") + MATH(EXPR found_vers_num "${found_major_vers}*100 + ${found_minor_vers}") + + if (found_vers_num LESS req_vers_num) + set( ${var_too_old} FALSE ) + else (found_vers_num LESS req_vers_num) + set( ${var_too_old} TRUE ) + endif (found_vers_num LESS req_vers_num) + +ENDMACRO(MACRO_ENSURE_VERSION2) -- cgit v1.2.1 From 1468725d8200bcc0f5c9130e4fde666e0f164285 Mon Sep 17 00:00:00 2001 From: Will Stephenson Date: Thu, 29 Nov 2007 13:23:40 +0000 Subject: Handle the presence of NetworkManager 0.7 in KDE4 builds *) Adapt MacroEnsureVersion.cmake to be able to check upper limits on version numbers *) Adapt kdelibs/cmake/modules/FindNetworkManager.cmake to report the version found *) Adapt kdebase/workspace/solid to select which version of NetworkManager support to build. *) Move NM 0.6 and NM 0.7 support into separate directories. NB This is build infrastructure only. There is no Solid backend for NM 0.7. Yet. CCMAIL: rdieter@math.unl.edu svn path=/trunk/KDE/kdelibs/; revision=742968 --- modules/MacroEnsureVersion.cmake | 134 ++++++++++++++++++++++++++------------- 1 file changed, 90 insertions(+), 44 deletions(-) (limited to 'modules/MacroEnsureVersion.cmake') diff --git a/modules/MacroEnsureVersion.cmake b/modules/MacroEnsureVersion.cmake index c6df537a..6797e5b7 100644 --- a/modules/MacroEnsureVersion.cmake +++ b/modules/MacroEnsureVersion.cmake @@ -1,66 +1,98 @@ -# This macro compares version numbers of the form "x.y.z" +# This file defines the following macros for developers to use in ensuring +# that installed software is of the right version: +# +# MACRO_ENSURE_VERSION - test that a version number is greater than +# or equal to some minimum +# MACRO_ENSURE_VERSION_RANGE - test that a version number is greater than +# or equal to some minimum and less than some +# maximum +# MACRO_ENSURE_VERSION2 - deprecated, do not use in new code +# + +# MACRO_ENSURE_VERSION +# This macro compares version numbers of the form "x.y.z" or "x.y" # MACRO_ENSURE_VERSION( FOO_MIN_VERSION FOO_VERSION_FOUND FOO_VERSION_OK) -# will set FOO_VERSIN_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION -# where both have to be in a 3-part-version format, leading and trailing -# text is ok, e.g. +# will set FOO_VERSION_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION +# Leading and trailing text is ok, e.g. # MACRO_ENSURE_VERSION( "2.5.31" "flex 2.5.4a" VERSION_OK) # which means 2.5.31 is required and "flex 2.5.4a" is what was found on the system # Copyright (c) 2006, David Faure, +# Copyright (c) 2007, Will Stephenson # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. -MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) - - # parse the parts of the version string - STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" req_major_vers "${requested_version}") - STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+" "\\1" req_minor_vers "${requested_version}") - STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)" "\\1" req_patch_vers "${requested_version}") - - STRING(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" found_major_vers "${found_version}") - STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" found_minor_vers "${found_version}") - STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" found_patch_vers "${found_version}") - - # compute an overall version number which can be compared at once - MATH(EXPR req_vers_num "${req_major_vers}*10000 + ${req_minor_vers}*100 + ${req_patch_vers}") - MATH(EXPR found_vers_num "${found_major_vers}*10000 + ${found_minor_vers}*100 + ${found_patch_vers}") - - if (found_vers_num LESS req_vers_num) - set( ${var_too_old} FALSE ) - else (found_vers_num LESS req_vers_num) - set( ${var_too_old} TRUE ) - endif (found_vers_num LESS req_vers_num) - -ENDMACRO(MACRO_ENSURE_VERSION) - - -# This macro compares version numbers of the form "x.y" -# MACRO_ENSURE_VERSION( FOO_MIN_VERSION FOO_VERSION_FOUND FOO_VERSION_OK) -# will set FOO_VERSIN_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION -# where both have to be in a 2-part-version format, leading and trailing -# text is ok, e.g. -# MACRO_ENSURE_VERSION( "0.5" "foo 0.6" VERSION_OK) -# which means 0.5 is required and "foo 0.6" is what was found on the system +# MACRO_ENSURE_VERSION_RANGE +# This macro ensures that a version number of the form +# "x.y.z" or "x.y" falls within a range defined by +# min_version <= found_version < max_version. +# If this expression holds, FOO_VERSION_OK will be set TRUE +# +# Example: MACRO_ENSURE_VERSION_RANGE3( "0.1.0" ${FOOCODE_VERSION} "0.7.0" FOO_VERSION_OK ) +# +# This macro will break silently if any of x,y,z are greater than 100. +# +# Copyright (c) 2007, Will Stephenson +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# NORMALIZE_VERSION +# Helper macro to convert version numbers of the form "x.y.z" +# to an integer equal to 10^4 * x + 10^2 * y + z +# +# This macro will break silently if any of x,y,z are greater than 100. +# # Copyright (c) 2006, David Faure, -# Copyright (c) 2007, Pino Toscano, +# Copyright (c) 2007, Will Stephenson # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. -MACRO(MACRO_ENSURE_VERSION2 requested_version found_version var_too_old) +# CHECK_RANGE_INCLUSIVE_LOWER +# Helper macro to check whether x <= y < z +# +# Copyright (c) 2007, Will Stephenson +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. - # parse the parts of the version string - STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+" "\\1" req_major_vers "${requested_version}") - STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)" "\\1" req_minor_vers "${requested_version}") - STRING(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+.*" "\\1" found_major_vers "${found_version}") - STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+).*" "\\1" found_minor_vers "${found_version}") +MACRO(NORMALIZE_VERSION _requested_version _normalized_version) + STRING(REGEX MATCH "[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" _threePartMatch "${_requested_version}") + if (_threePartMatch) + # parse the parts of the version string + STRING(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major_vers "${_requested_version}") + STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor_vers "${_requested_version}") + STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch_vers "${_requested_version}") + else (_threePartMatch) + STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+" "\\1" _major_vers "${_requested_version}") + STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)" "\\1" _minor_vers "${_requested_version}") + set(_patch_vers "0") + endif (_threePartMatch) # compute an overall version number which can be compared at once - MATH(EXPR req_vers_num "${req_major_vers}*100 + ${req_minor_vers}") - MATH(EXPR found_vers_num "${found_major_vers}*100 + ${found_minor_vers}") + MATH(EXPR ${_normalized_version} "${_major_vers}*10000 + ${_minor_vers}*100 + ${_patch_vers}") +ENDMACRO(NORMALIZE_VERSION) + +MACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER _lower_limit _value _upper_limit _ok) + if (${_value} LESS ${_lower_limit}) + set( ${_ok} FALSE ) + elseif (${_value} EQUAL ${_lower_limit}) + set( ${_ok} TRUE ) + elseif (${_value} EQUAL ${_upper_limit}) + set( ${_ok} FALSE ) + elseif (${_value} GREATER ${_upper_limit}) + set( ${_ok} FALSE ) + else (${_value} LESS ${_lower_limit}) + set( ${_ok} TRUE ) + endif (${_value} LESS ${_lower_limit}) +ENDMACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER) + +MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) + NORMALIZE_VERSION( ${requested_version} req_vers_num ) + NORMALIZE_VERSION( ${found_version} found_vers_num ) if (found_vers_num LESS req_vers_num) set( ${var_too_old} FALSE ) @@ -68,4 +100,18 @@ MACRO(MACRO_ENSURE_VERSION2 requested_version found_version var_too_old) set( ${var_too_old} TRUE ) endif (found_vers_num LESS req_vers_num) +ENDMACRO(MACRO_ENSURE_VERSION) + +MACRO(MACRO_ENSURE_VERSION2 requested_version2 found_version2 var_too_old2) + MACRO_ENSURE_VERSION( ${requested_version2} ${found_version2} ${var_too_old2}) ENDMACRO(MACRO_ENSURE_VERSION2) + +MACRO(MACRO_ENSURE_VERSION_RANGE min_version found_version max_version var_ok) + NORMALIZE_VERSION( ${min_version} req_vers_num ) + NORMALIZE_VERSION( ${found_version} found_vers_num ) + NORMALIZE_VERSION( ${max_version} max_vers_num ) + + MACRO_CHECK_RANGE_INCLUSIVE_LOWER( ${req_vers_num} ${found_vers_num} ${max_vers_num} ${var_ok}) +ENDMACRO(MACRO_ENSURE_VERSION_RANGE) + + -- cgit v1.2.1