Backport lots of new features from the 1.41.0 branch.
[boost:cmake.git] / tools / build / CMake / install_me / BoostConfigVersion.cmake
1 #
2 # Copyright (C) Troy D. Straszheim
3 #
4 # Distributed under the Boost Software License, Version 1.0.
5 # See accompanying file LICENSE_1_0.txt or copy at
6 #   http://www.boost.org/LICENSE_1_0.txt
7 #
8 #
9 # Determine if we have a version of boost available that works
10 #
11 #
12 get_filename_component(CWD ${CMAKE_CURRENT_LIST_FILE} PATH)
13
14 file(GLOB AVAILABLE_VERSIONFILES RELATIVE ${CWD} "${CWD}/Boost-*.cmake")
15 message("BoostConfigVersion: AVAILABLE_VERSIONFILES=${AVAILABLE_VERSIONFILES}")
16
17 #
18 #  
19 #
20 if (PACKAGE_FIND_VERSION AND EXISTS "${CWD}/Boost-${PACKAGE_FIND_VERSION}.cmake")
21   #
22   #  Exact version
23   #
24   set(BOOST_FOUND TRUE)
25   set(PACKAGE_VERSION ${PACKAGE_FIND_VERSION})
26   set(PACKAGE_VERSION_EXACT TRUE)
27   set(PACKAGE_VERSION_COMPATIBLE TRUE)
28   set(PACKAGE_VERSION_UNSUITABLE FALSE)
29
30 elseif(AVAILABLE_VERSIONFILES)
31
32   #
33   #  Find any version
34   #
35   list(SORT AVAILABLE_VERSIONFILES)
36   list(REVERSE AVAILABLE_VERSIONFILES)
37   message("revlist = ${AVAILABLE_VERSIONFILES}")
38   list(GET AVAILABLE_VERSIONFILES 0 MOSTRECENT)
39   message("Greatest version found is ${MOSTRECENT}")
40   string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" FOUNDVERSION ${MOSTRECENT})
41   message("FOUNDVERSION=${FOUNDVERSION}")
42
43   if(PACKAGE_FIND_VERSION)
44     if(${PACKAGE_FIND_VERSION} STRLESS ${FOUNDVERSION})
45       #
46       #  Okay, we have newer than requested
47       #
48       set(PACKAGE_VERSION ${FOUNDVERSION})
49       set(PACKAGE_VERSION_EXACT FALSE)
50       set(PACKAGE_VERSION_COMPATIBLE TRUE)
51       set(PACKAGE_VERSION_UNSUITABLE FALSE)
52     else(${PACKAGE_FIND_VERSION} STRGREATER ${FOUNDVERSION})
53       #
54       #  Sorry, we only have older than requested
55       #
56       set(PACKAGE_VERSION ${FOUNDVERSION})
57       set(PACKAGE_VERSION_EXACT FALSE)
58       set(PACKAGE_VERSION_COMPATIBLE FALSE)
59       set(PACKAGE_VERSION_UNSUITABLE TRUE)
60     endif()
61   else()
62     set(PACKAGE_VERSION ${FOUNDVERSION})
63   endif()
64 endif()
65