Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gui/cmake/DetermineVersion.cmake @ 2862

Last change on this file since 2862 was 2710, checked in by rgrieder, 16 years ago

Merged buildsystem3 containing buildsystem2 containing Adi's buildsystem branch back to the trunk.
Please update the media directory if you were not using buildsystem3 before.

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1 #
2 #             ORXONOX - the hottest 3D action shooter ever to exist
3 #                             > www.orxonox.net <
4 #
5 #        This program is free software; you can redistribute it and/or
6 #         modify it under the terms of the GNU General Public License
7 #        as published by the Free Software Foundation; either version 2
8 #            of the License, or (at your option) any later version.
9 #
10 #       This program is distributed in the hope that it will be useful,
11 #        but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #        MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 #                 GNU General Public License for more details.
14 #
15 #   You should have received a copy of the GNU General Public License along
16 #      with this program; if not, write to the Free Software Foundation,
17 #     Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 #
19 #
20 #  Author:
21 #    Reto Grieder
22 #  Description:
23 #    Inspects a given file for the following expressions
24 #    "NAME_MAJOR_VERSION #"
25 #    "NAME_MINOR_VERSION #"
26 #    "NAME_PATCH_VERSION #"
27 #    and sets NAME_VERSION accordingly. NAME_PART_VERSION variables are also
28 #    set. If you wish to look for different parts (e.g. "first" "second", etc.)
29 #    simply deliver them as additional arguments (have to be three though).
30 #
31
32FUNCTION(DETERMINE_VERSION _name _file)
33  IF(EXISTS ${_file})
34    FILE(READ ${_file} _file_content)
35    SET(_parts ${ARGN})
36    LIST(LENGTH _parts _parts_length)
37    IF(NOT ${_parts_length} EQUAL 3)
38      SET(_parts MAJOR MINOR PATCH)
39    ENDIF()
40
41    FOREACH(_part ${_parts})
42      STRING(REGEX MATCH "${_name}_VERSION_${_part} +([0-9]+)" _match ${_file_content})
43      IF(_match)
44        SET(${_name}_VERSION_${_part} ${CMAKE_MATCH_1})
45        SET(${_name}_VERSION_${_part} ${CMAKE_MATCH_1} PARENT_SCOPE)
46      ELSE()
47        SET(${_name}_VERSION_${_part} "0")
48        SET(${_name}_VERSION_${_part} "0" PARENT_SCOPE)
49      ENDIF()
50      IF("${_parts}" MATCHES "^${_part}") # First?
51        SET(${_name}_VERSION "${${_name}_VERSION_${_part}}")
52      ELSE()
53        SET(${_name}_VERSION "${${_name}_VERSION}.${${_name}_VERSION_${_part}}")
54      ENDIF()
55    ENDFOREACH(_part)
56    SET(${_name}_VERSION "${${_name}_VERSION}" PARENT_SCOPE)
57  ENDIF(EXISTS ${_file})
58ENDFUNCTION(DETERMINE_VERSION)
Note: See TracBrowser for help on using the repository browser.