Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/cmake/FindPackageHandleAdvancedArgs.cmake @ 3343

Last change on this file since 3343 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.8 KB
RevLine 
[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 #    Extension of the standard module "FindPackageHandleStandardArgs".
24 #    This function also checks the version requirements. Also regards the
25 #    EXACT keyword if specified in FIND_PACKAGE(...).
26 #
27 
[2613]28INCLUDE(FindPackageHandleStandardArgs)
29INCLUDE(CompareVersionStrings)
30
31FUNCTION(FIND_PACKAGE_HANDLE_ADVANCED_ARGS _name _fail_msg _version)
32
33  # Modify the message to include version requirements
34  IF("${_fail_msg}" STREQUAL "DEFAULT_MSG")
35    SET(_fail_msg_adv "Could NOT find ${_name}")
[2624]36  ELSE()
[2613]37    SET(_fail_msg_adv "${_fail_msg}")
[2624]38  ENDIF()
[2613]39  IF(${_name}_FIND_VERSION_EXACT)
[2631]40    SET(_fail_msg_adv "${_fail_msg_adv} (version requirements: exactly ${${_name}_FIND_VERSION})")
[2624]41  ELSE()
[2631]42    SET(_fail_msg_adv "${_fail_msg_adv} (version requirements: at least ${${_name}_FIND_VERSION})")
[2624]43  ENDIF()
[2613]44  FIND_PACKAGE_HANDLE_STANDARD_ARGS("${_name}" "${_fail_msg_adv}" ${ARGN})
45  STRING(TOUPPER ${_name} _NAME_UPPER)
46
47  # Also check version requirements if given to FindPackage(...)
48  IF(${_name}_FIND_VERSION)
49    # Note: the last argument of the function tells it to cut the first
50    #       version string instead of padding it with zeros if necessary
51    COMPARE_VERSION_STRINGS("${_version}" "${${_name}_FIND_VERSION}" _compatible TRUE)
52    IF(${_name}_FIND_VERSION_EXACT AND NOT _compatible EQUAL 0)
53      MESSAGE(FATAL_ERROR "Exact ${_name} version required is ${${_name}_FIND_VERSION}\n"
54                          "Your version is ${_version}")
55      SET(${_NAME_UPPER}_FOUND FALSE)
56    ELSEIF(_compatible LESS 0)
57      MESSAGE(FATAL_ERROR "Minimum ${_name} version required is ${${_name}_FIND_VERSION}\n"
58                          "Your version is ${_version}")
59      SET(${_NAME_UPPER}_FOUND FALSE)
[2624]60    ENDIF()
[2613]61  ENDIF(${_name}_FIND_VERSION)
62
63  # Raise scope (FindPackageHandleStandardArgs uses PARENT_SCOPE)
64  SET(${_NAME_UPPER}_FOUND ${${_NAME_UPPER}_FOUND} PARENT_SCOPE)
65
66ENDFUNCTION(FIND_PACKAGE_HANDLE_ADVANCED_ARGS)
Note: See TracBrowser for help on using the repository browser.