| [2626] | 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 | 
|---|
| [7151] | 24 | #    "NAME_VERSION_MAJOR #" | 
|---|
|  | 25 | #    "NAME_VERSION_MINOR #" | 
|---|
|  | 26 | #    "NAME_VERSION_PATCH #" | 
|---|
| [2626] | 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 | # | 
|---|
| [2573] | 31 |  | 
|---|
| [2613] | 32 | FUNCTION(DETERMINE_VERSION _name _file) | 
|---|
|  | 33 | IF(EXISTS ${_file}) | 
|---|
|  | 34 | FILE(READ ${_file} _file_content) | 
|---|
| [2577] | 35 | SET(_parts ${ARGN}) | 
|---|
|  | 36 | LIST(LENGTH _parts _parts_length) | 
|---|
|  | 37 | IF(NOT ${_parts_length} EQUAL 3) | 
|---|
|  | 38 | SET(_parts MAJOR MINOR PATCH) | 
|---|
| [2624] | 39 | ENDIF() | 
|---|
| [2577] | 40 |  | 
|---|
|  | 41 | FOREACH(_part ${_parts}) | 
|---|
|  | 42 | STRING(REGEX MATCH "${_name}_VERSION_${_part} +([0-9]+)" _match ${_file_content}) | 
|---|
|  | 43 | IF(_match) | 
|---|
| [2613] | 44 | SET(${_name}_VERSION_${_part} ${CMAKE_MATCH_1}) | 
|---|
|  | 45 | SET(${_name}_VERSION_${_part} ${CMAKE_MATCH_1} PARENT_SCOPE) | 
|---|
| [2624] | 46 | ELSE() | 
|---|
| [2613] | 47 | SET(${_name}_VERSION_${_part} "0") | 
|---|
|  | 48 | SET(${_name}_VERSION_${_part} "0" PARENT_SCOPE) | 
|---|
| [2624] | 49 | ENDIF() | 
|---|
| [2577] | 50 | IF("${_parts}" MATCHES "^${_part}") # First? | 
|---|
| [2613] | 51 | SET(${_name}_VERSION "${${_name}_VERSION_${_part}}") | 
|---|
| [2624] | 52 | ELSE() | 
|---|
| [2613] | 53 | SET(${_name}_VERSION "${${_name}_VERSION}.${${_name}_VERSION_${_part}}") | 
|---|
| [2624] | 54 | ENDIF() | 
|---|
| [2577] | 55 | ENDFOREACH(_part) | 
|---|
| [2613] | 56 | SET(${_name}_VERSION "${${_name}_VERSION}" PARENT_SCOPE) | 
|---|
|  | 57 | ENDIF(EXISTS ${_file}) | 
|---|
|  | 58 | ENDFUNCTION(DETERMINE_VERSION) | 
|---|