Warning, /office/calligra/cmake/modules/MacroEnsureVersion.cmake is written in an unsupported language. File is not indexed.
0001 # This file defines the following macros for developers to use in ensuring 0002 # that installed software is of the right version: 0003 # 0004 # MACRO_ENSURE_VERSION - test that a version number is greater than 0005 # or equal to some minimum 0006 # MACRO_ENSURE_VERSION_RANGE - test that a version number is greater than 0007 # or equal to some minimum and less than some 0008 # maximum 0009 # MACRO_ENSURE_VERSION2 - deprecated, do not use in new code 0010 # 0011 0012 # MACRO_ENSURE_VERSION 0013 # This macro compares version numbers of the form "x.y.z" or "x.y" 0014 # MACRO_ENSURE_VERSION( FOO_MIN_VERSION FOO_VERSION_FOUND FOO_VERSION_OK) 0015 # will set FOO_VERSION_OK to true if FOO_VERSION_FOUND >= FOO_MIN_VERSION 0016 # Leading and trailing text is ok, e.g. 0017 # MACRO_ENSURE_VERSION( "2.5.31" "flex 2.5.4a" VERSION_OK) 0018 # which means 2.5.31 is required and "flex 2.5.4a" is what was found on the system 0019 0020 # Copyright (c) 2006, David Faure, <faure@kde.org> 0021 # Copyright (c) 2007, Will Stephenson <wstephenson@kde.org> 0022 # 0023 # Redistribution and use is allowed according to the terms of the BSD license. 0024 # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 0025 0026 # MACRO_ENSURE_VERSION_RANGE 0027 # This macro ensures that a version number of the form 0028 # "x.y.z" or "x.y" falls within a range defined by 0029 # min_version <= found_version < max_version. 0030 # If this expression holds, FOO_VERSION_OK will be set TRUE 0031 # 0032 # Example: MACRO_ENSURE_VERSION_RANGE3( "0.1.0" ${FOOCODE_VERSION} "0.7.0" FOO_VERSION_OK ) 0033 # 0034 # This macro will break silently if any of x,y,z are greater than 100. 0035 # 0036 # Copyright (c) 2007, Will Stephenson <wstephenson@kde.org> 0037 # 0038 # Redistribution and use is allowed according to the terms of the BSD license. 0039 # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 0040 0041 # NORMALIZE_VERSION 0042 # Helper macro to convert version numbers of the form "x.y.z" 0043 # to an integer equal to 10^4 * x + 10^2 * y + z 0044 # 0045 # This macro will break silently if any of x,y,z are greater than 100. 0046 # 0047 # Copyright (c) 2006, David Faure, <faure@kde.org> 0048 # Copyright (c) 2007, Will Stephenson <wstephenson@kde.org> 0049 # 0050 # Redistribution and use is allowed according to the terms of the BSD license. 0051 # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 0052 0053 # CHECK_RANGE_INCLUSIVE_LOWER 0054 # Helper macro to check whether x <= y < z 0055 # 0056 # Copyright (c) 2007, Will Stephenson <wstephenson@kde.org> 0057 # 0058 # Redistribution and use is allowed according to the terms of the BSD license. 0059 # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 0060 0061 0062 MACRO(NORMALIZE_VERSION _requested_version _normalized_version) 0063 STRING(REGEX MATCH "[^0-9]*[0-9]+\\.[0-9]+\\.[0-9]+.*" _threePartMatch "${_requested_version}") 0064 if (_threePartMatch) 0065 # parse the parts of the version string 0066 STRING(REGEX REPLACE "[^0-9]*([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _major_vers "${_requested_version}") 0067 STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _minor_vers "${_requested_version}") 0068 STRING(REGEX REPLACE "[^0-9]*[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _patch_vers "${_requested_version}") 0069 else (_threePartMatch) 0070 STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+" "\\1" _major_vers "${_requested_version}") 0071 STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)" "\\1" _minor_vers "${_requested_version}") 0072 set(_patch_vers "0") 0073 endif (_threePartMatch) 0074 0075 # compute an overall version number which can be compared at once 0076 MATH(EXPR ${_normalized_version} "${_major_vers}*10000 + ${_minor_vers}*100 + ${_patch_vers}") 0077 ENDMACRO(NORMALIZE_VERSION) 0078 0079 MACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER _lower_limit _value _upper_limit _ok) 0080 if (${_value} LESS ${_lower_limit}) 0081 set( ${_ok} FALSE ) 0082 elseif (${_value} EQUAL ${_lower_limit}) 0083 set( ${_ok} TRUE ) 0084 elseif (${_value} EQUAL ${_upper_limit}) 0085 set( ${_ok} FALSE ) 0086 elseif (${_value} GREATER ${_upper_limit}) 0087 set( ${_ok} FALSE ) 0088 else (${_value} LESS ${_lower_limit}) 0089 set( ${_ok} TRUE ) 0090 endif (${_value} LESS ${_lower_limit}) 0091 ENDMACRO(MACRO_CHECK_RANGE_INCLUSIVE_LOWER) 0092 0093 MACRO(MACRO_ENSURE_VERSION requested_version found_version var_too_old) 0094 NORMALIZE_VERSION( ${requested_version} req_vers_num ) 0095 NORMALIZE_VERSION( ${found_version} found_vers_num ) 0096 0097 if (found_vers_num LESS req_vers_num) 0098 set( ${var_too_old} FALSE ) 0099 else (found_vers_num LESS req_vers_num) 0100 set( ${var_too_old} TRUE ) 0101 endif (found_vers_num LESS req_vers_num) 0102 0103 ENDMACRO(MACRO_ENSURE_VERSION) 0104 0105 MACRO(MACRO_ENSURE_VERSION2 requested_version2 found_version2 var_too_old2) 0106 MACRO_ENSURE_VERSION( ${requested_version2} ${found_version2} ${var_too_old2}) 0107 ENDMACRO(MACRO_ENSURE_VERSION2) 0108 0109 MACRO(MACRO_ENSURE_VERSION_RANGE min_version found_version max_version var_ok) 0110 NORMALIZE_VERSION( ${min_version} req_vers_num ) 0111 NORMALIZE_VERSION( ${found_version} found_vers_num ) 0112 NORMALIZE_VERSION( ${max_version} max_vers_num ) 0113 0114 MACRO_CHECK_RANGE_INCLUSIVE_LOWER( ${req_vers_num} ${found_vers_num} ${max_vers_num} ${var_ok}) 0115 ENDMACRO(MACRO_ENSURE_VERSION_RANGE) 0116 0117