Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/mac_osx/cmake/tools/CheckPackageVersion.cmake @ 8043

Last change on this file since 8043 was 7582, checked in by rgrieder, 14 years ago

Added CMake code for OS X package configuration.
Not guaranteed to work… Mainly because it requires several adjustments of the paths.

  • Property svn:eol-style set to native
File size: 2.6 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 #    Check package version info
24 #    MAJOR: Breaking change
25 #    MINOR: No breaking changes by the dependency package
26 #           For example any code running on 3.0 should still run on 3.1
27 #           But you can specify that the code only runs on 3.1 and higher
28 #           or 4.0 and higher (so both 3.1 and 4.0 will work).
29
30MACRO(CHECK_PACKAGE_VERSION)
31  SET(_allowed_minimum_versions ${ARGN})
32
33  IF(NOT EXISTS ${DEPENDENCY_PACKAGE_DIR}/version.txt)
34    SET(DEPENDENCY_VERSION 1.0)
35  ELSE()
36    # Get version from file
37    FILE(READ ${DEPENDENCY_PACKAGE_DIR}/version.txt _file_content)
38    SET(_match)
39    STRING(REGEX MATCH "([0-9]+.[0-9]+)" _match ${_file_content})
40    IF(_match)
41      SET(DEPENDENCY_VERSION ${_match})
42    ELSE()
43      MESSAGE(FATAL_ERROR "The version.txt file in the dependency file has corrupt version information.")
44    ENDIF()
45  ENDIF()
46 
47  INCLUDE(CompareVersionStrings)
48  SET(_version_match FALSE)
49  FOREACH(_version ${_allowed_minimum_versions})
50    # Get major version
51    STRING(REGEX REPLACE "^([0-9]+)\\..*$" "\\1" _major_version "${_version}")
52    COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${_major_version} _result TRUE)
53    IF(_result EQUAL 0)
54      COMPARE_VERSION_STRINGS(${DEPENDENCY_VERSION} ${_version} _result FALSE)
55      IF(NOT _result LESS 0)
56        SET(_version_match TRUE)
57      ENDIF()
58    ENDIF()
59  ENDFOREACH(_version)
60  IF(NOT _version_match)
61    MESSAGE(FATAL_ERROR "Your dependency package version is ${DEPENDENCY_VERSION}\n"
62            "Possible required versions: ${_allowed_minimum_versions}\n"
63            "You can get a new version from www.orxonox.net")
64  ENDIF()
65 
66ENDMACRO(CHECK_PACKAGE_VERSION)
Note: See TracBrowser for help on using the repository browser.