File: ExtractVersion.cmake

package info (click to toggle)
robot-testing-framework 2.0.1%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,764 kB
  • sloc: cpp: 7,408; ansic: 4,493; ada: 200; perl: 160; python: 52; makefile: 35; ruby: 25; xml: 11
file content (88 lines) | stat: -rw-r--r-- 2,949 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#.rst:
# ExtractVersion
# --------------
#
# Extracts version numbers from a version string::
#
#  extract_version (<name> [REVERSE_NAME])
#
#
# Tries to extract the following variables (the second version is used
# if REVERSE_NAME is set as argument)::
#
#   <name>_MAJOR_VERSION or <name>_VERSION_MAJOR - <name> major version
#   <name>_MINOR_VERSION or <name>_VERSION_MINOR - <name> minor version
#   <name>_PATCH_VERSION or <name>_VERSION_PATCH - <name> patch version
#   <name>_TWEAK_VERSION or <name>_VERSION_TWEAK - <name> tweak version
#   <name>_VERSION_COUNT - number of version components, 0 to 4

#=============================================================================
# Copyright 2013 Istituto Italiano di Tecnologia (IIT)
#   Authors: Daniele E. Domenichelli <daniele.domenichelli@iit.it>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
#  License text for the above reference.)


if(DEFINED __EXTRACT_VERSION_INCLUDED)
  return()
endif()
set(__EXTRACT_VERSION_INCLUDED TRUE)


macro(EXTRACT_VERSION _name)
    if("x${ARGV2}" STREQUAL "xREVERSE_NAME")
        set(_reverse 1)
    endif()

    if(${_name}_VERSION)
        string(REPLACE "." ";" _version_list ${${_name}_VERSION})
        list(LENGTH _version_list _version_size)
        if (_version_size GREATER 0)
            if(NOT _reverse)
                list(GET _version_list 0 ${_name}_MAJOR_VERSION)
            else()
                list(GET _version_list 0 ${_name}_VERSION_MAJOR)
            endif()
        endif()
        if (_version_size GREATER 1)
            if(NOT _reverse)
                list(GET _version_list 1 ${_name}_MINOR_VERSION)
            else()
                list(GET _version_list 1 ${_name}_VERSION_MINOR)
            endif()
        endif()
        if (_version_size GREATER 2)
            if(NOT _reverse)
                list(GET _version_list 2 ${_name}_PATCH_VERSION)
            else()
                list(GET _version_list 2 ${_name}_VERSION_PATCH)
            endif()
        endif()
        if (_version_size GREATER 3)
            if(NOT _reverse)
                list(GET _version_list 3 ${_name}_TWEAK_VERSION)
            else()
                list(GET _version_list 3 ${_name}_VERSION_TWEAK)
            endif()
        endif()

        if(${_version_size} GREATER 4)
            set(${_name}_VERSION_COUNT 4)
        else()
            set(${_name}_VERSION_COUNT ${_version_size})
        endif()
    else()
        set(${_name}_VERSION_COUNT 0)
    endif()

    unset(_version_list)
    unset(_version_size)
endmacro()