Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem2/cmake/DetermineVersion.cmake @ 2613

Last change on this file since 2613 was 2613, checked in by rgrieder, 15 years ago
  • Added FindPackageHandleAdvancedArgs.cmake module that invokes FindPackageHandleStandardArgs and then checks the version requirements. Usage: FIND_PACKAGE_HANDLE_ADVANCED_ARGS(NAME MSG VERSION VARS) (like the orginal CMake module, but with the additional version argument)
  • Updated DetermineVersion.cmake and HandleLibraryTypes.cmake to use FUNCTION instead of MACRO and also removed CACHE setting of the veriables (unnecessary).
  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1#    DetermineVersion.cmake - CMake Module to get the version of a library from
2#                             a header file.
3#    Author: Reto '1337' Grieder (2009)
4#
5#    This program is free software; you can redistribute it and/or modify
6#    it under the terms of the GNU General Public License as published by
7#    the Free Software Foundation; either version 2 of the License, or
8#    (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
16#    along with this program; if not, write to the Free Software
17#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
18
19FUNCTION(DETERMINE_VERSION _name _file)
20  IF(EXISTS ${_file})
21    FILE(READ ${_file} _file_content)
22    SET(_parts ${ARGN})
23    LIST(LENGTH _parts _parts_length)
24    IF(NOT ${_parts_length} EQUAL 3)
25      SET(_parts MAJOR MINOR PATCH)
26    ENDIF(NOT ${_parts_length} EQUAL 3)
27
28    FOREACH(_part ${_parts})
29      STRING(REGEX MATCH "${_name}_VERSION_${_part} +([0-9]+)" _match ${_file_content})
30      IF(_match)
31        SET(${_name}_VERSION_${_part} ${CMAKE_MATCH_1})
32        SET(${_name}_VERSION_${_part} ${CMAKE_MATCH_1} PARENT_SCOPE)
33      ELSE(_match)
34        SET(${_name}_VERSION_${_part} "0")
35        SET(${_name}_VERSION_${_part} "0" PARENT_SCOPE)
36      ENDIF(_match)
37      IF("${_parts}" MATCHES "^${_part}") # First?
38        SET(${_name}_VERSION "${${_name}_VERSION_${_part}}")
39      ELSE("${_parts}" MATCHES "^${_part}")
40        SET(${_name}_VERSION "${${_name}_VERSION}.${${_name}_VERSION_${_part}}")
41      ENDIF("${_parts}" MATCHES "^${_part}")
42    ENDFOREACH(_part)
43    SET(${_name}_VERSION "${${_name}_VERSION}" PARENT_SCOPE)
44  ENDIF(EXISTS ${_file})
45ENDFUNCTION(DETERMINE_VERSION)
Note: See TracBrowser for help on using the repository browser.