aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Stephenson <wstephenson@kde.org>2007-11-29 13:23:40 +0000
committerWill Stephenson <wstephenson@kde.org>2007-11-29 13:23:40 +0000
commit1468725d8200bcc0f5c9130e4fde666e0f164285 (patch)
tree462ca142e06d4dcd3900c1877afd5eef3ad8aab9
parent657bb4ea3dbad5d7bb22974833946ef7cf70675d (diff)
downloadextra-cmake-modules-1468725d8200bcc0f5c9130e4fde666e0f164285.tar.gz
extra-cmake-modules-1468725d8200bcc0f5c9130e4fde666e0f164285.tar.bz2
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
-rw-r--r--modules/FindNetworkManager.cmake6
-rw-r--r--modules/MacroEnsureVersion.cmake134
2 files changed, 94 insertions, 46 deletions
diff --git a/modules/FindNetworkManager.cmake b/modules/FindNetworkManager.cmake
index e931d091..5fa21274 100644
--- a/modules/FindNetworkManager.cmake
+++ b/modules/FindNetworkManager.cmake
@@ -5,6 +5,7 @@
# NETWORKMANAGER_INCLUDE_DIR - the NetworkManager include directory
# NETWORKMANAGER_LIBRARY - the libraries needed to use NetworkManager
# NETWORKMANAGER_DEFINITIONS - Compiler switches required for using NetworkManager
+# NETWORKMANAGER_VERSION - version number of NetworkManager
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
# Copyright (c) 2007, Will Stephenson, <wstephenson@kde.org>
@@ -22,13 +23,14 @@ IF (NOT WIN32)
# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
INCLUDE(UsePkgConfig)
- PKGCONFIG(NetworkManager _NetworkManagerIncDir _NetworkManagerLinkDir _NetworkManagerLinkFlags _NetworkManagerCflags)
+ SET(NETWORKMANAGER_VERSION)
+ PKGCONFIG_VERSION(NetworkManager _NetworkManagerIncDir _NetworkManagerLinkDir _NetworkManagerLinkFlags _NetworkManagerCflags NETWORKMANAGER_VERSION)
SET(NETWORKMANAGER_DEFINITIONS ${_NetworkManagerCflags})
PKGCONFIG(libnm-util _libnm-utilIncDir _libnm-utilLinkDir _libnm-utilLinkFlags _libnm-utilCflags)
SET(NM-UTILS_DEFINITIONS ${_libnm-utilCflags})
ENDIF (NOT WIN32)
-MESSAGE(STATUS "Found NetworkManager: ${_NetworkManagerLinkFlags}")
+MESSAGE(STATUS "Found NetworkManager ${NETWORKMANAGER_VERSION}: ${_NetworkManagerLinkFlags}")
FIND_PATH(NETWORKMANAGER_INCLUDE_DIR NetworkManager/NetworkManager.h
PATHS
${_NetworkManagerIncDir}
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, <faure@kde.org>
+# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
#
# 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 <wstephenson@kde.org>
+#
+# 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, <faure@kde.org>
-# Copyright (c) 2007, Pino Toscano, <pino@kde.org>
+# Copyright (c) 2007, Will Stephenson <wstephenson@kde.org>
#
# 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 <wstephenson@kde.org>
+#
+# 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)
+
+