]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/cmake/FindHana.cmake
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / cmake / FindHana.cmake
1 # Copyright Louis Dionne 2013-2016
2 # Distributed under the Boost Software License, Version 1.0.
3 # (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
4 #
5 #
6 # This CMake module finds the Hana library. It sets the following CMake
7 # variables:
8 #
9 # Hana_FOUND
10 # Set to 1 when Hana is found, set to 0 otherwise.
11 #
12 # Hana_INCLUDE_DIRS
13 # If Hana is found, this is a list containing Hana's include/ directory,
14 # along with that of any dependency of Hana. Since Hana has no external
15 # dependencies as a library, this will always contain only Hana's include/
16 # directory. This is provided for consistency with normal CMake Find-modules.
17 # If Hana is not found, this is not set.
18 #
19 #
20 # The following variables can be used to customize the behavior of the module:
21 #
22 # Hana_ROOT
23 # The path to Hana's installation prefix. If this is specified, this prefix
24 # will be searched first while looking for Hana. If Hana is not found in
25 # this prefix, the usual system directories are searched.
26 #
27 # Hana_INSTALL_PREFIX
28 # If Hana can't be found and this is set to something, Hana will be downloaded
29 # and installed to that directory. This can be very useful for installing
30 # Hana as a local dependency of the current project. A suggestion is to set
31 # `Hana_INSTALL_PREFIX` to `project_root/ext/hana`, and to Git-ignore the
32 # whole `ext/` subdirectory, to avoid tracking external dependencies in
33 # source control. Note that when `Hana_INSTALL_PREFIX` is specified, the
34 # version of Hana must be provided explicitly to `find_package`.
35 #
36 # Hana_ENABLE_TESTS
37 # If Hana is installed as an external project and this is set to true, the
38 # tests will be run whenever Hana is updated. By default, this is set to
39 # false because the tests tend to be quite long.
40
41
42 ##############################################################################
43 # Sanitize input variables
44 ##############################################################################
45 if (DEFINED Hana_FIND_VERSION AND "${Hana_FIND_VERSION}" VERSION_LESS "0.6.0")
46 message(FATAL_ERROR
47 "This FindHana.cmake module may not be used with Hana < 0.6.0, "
48 "because Hana did not carry version information before that.")
49 endif()
50
51 if (DEFINED Hana_INSTALL_PREFIX AND NOT DEFINED Hana_FIND_VERSION)
52 message(FATAL_ERROR
53 "The version of Hana must be specified when cloning locally. "
54 "Otherwise, we wouldn't know which version to clone.")
55 endif()
56
57
58 ##############################################################################
59 # First, try to find the library locally (using Hana_ROOT as a hint, if provided)
60 ##############################################################################
61 find_path(Hana_INCLUDE_DIR
62 NAMES boost/hana.hpp
63 HINTS "${Hana_ROOT}/include"
64 DOC "Include directory for the Hana library"
65 )
66
67 # Extract Hana's version from <boost/hana/version.hpp>, and set
68 # Hana_VERSION_XXX variables accordingly.
69 if (EXISTS "${Hana_INCLUDE_DIR}")
70 foreach(level MAJOR MINOR PATCH)
71 file(STRINGS
72 ${Hana_INCLUDE_DIR}/boost/hana/version.hpp
73 Hana_VERSION_${level}
74 REGEX "#define BOOST_HANA_${level}_VERSION"
75 )
76 string(REGEX MATCH "([0-9]+)" Hana_VERSION_${level} "${Hana_VERSION_${level}}")
77 endforeach()
78
79 set(Hana_VERSION_STRING "${Hana_VERSION_MAJOR}.${Hana_VERSION_MINOR}.${Hana_VERSION_PATCH}")
80 endif()
81
82 # Temporarily override the quietness level to avoid producing a "not-found"
83 # message when we're going to install anyway.
84 if (Hana_INSTALL_PREFIX)
85 set(_hana_quiet_level ${Hana_FIND_QUIETLY})
86 set(Hana_FIND_QUIETLY 1)
87 endif()
88 include(FindPackageHandleStandardArgs)
89 find_package_handle_standard_args(Hana
90 REQUIRED_VARS Hana_INCLUDE_DIR
91 VERSION_VAR Hana_VERSION_STRING
92 )
93 if (Hana_INSTALL_PREFIX)
94 set(Hana_FIND_QUIETLY ${_hana_quiet_level})
95 endif()
96
97 if (Hana_FOUND)
98 set(Hana_INCLUDE_DIRS "${Hana_INCLUDE_DIR}")
99 return()
100 endif()
101
102
103 ##############################################################################
104 # Otherwise, if Hana_INSTALL_PREFIX was specified, try to install the library.
105 ##############################################################################
106 if (NOT Hana_FOUND AND DEFINED Hana_INSTALL_PREFIX)
107 if (DEFINED Hana_ENABLE_TESTS)
108 set(_hana_test_cmd ${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/hana --target check)
109 endif()
110
111 include(ExternalProject)
112 ExternalProject_Add(Hana EXCLUDE_FROM_ALL 1
113 SOURCE_DIR ${Hana_INSTALL_PREFIX}
114 PREFIX ${CMAKE_CURRENT_BINARY_DIR}/hana
115 BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/hana
116 DOWNLOAD_DIR ${CMAKE_CURRENT_BINARY_DIR}/hana/_download
117 STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/hana/_stamps
118 TMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/hana/_tmp
119
120 # Download step
121 DOWNLOAD_NAME "hana-v${Hana_FIND_VERSION}.tar.gz"
122 URL "https://github.com/boostorg/hana/tarball/v${Hana_FIND_VERSION}"
123 TIMEOUT 20
124
125 # Configure step
126 CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
127
128 # No build step because Hana is header-only
129 BUILD_COMMAND ""
130
131 # No install step
132 INSTALL_COMMAND ""
133
134 # Test step
135 TEST_COMMAND ${_hana_test_cmd}
136 )
137
138 if ("${Hana_FIND_VERSION}" MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
139 set(Hana_VERSION_MAJOR ${CMAKE_MATCH_1})
140 set(Hana_VERSION_MINOR ${CMAKE_MATCH_2})
141 set(Hana_VERSION_PATCH ${CMAKE_MATCH_3})
142 set(Hana_VERSION_STRING "${Hana_VERSION_MAJOR}.${Hana_VERSION_MINOR}.${Hana_VERSION_PATCH}")
143 endif()
144
145 set(Hana_INCLUDE_DIR "${Hana_INSTALL_PREFIX}/include")
146 find_package_handle_standard_args(Hana
147 REQUIRED_VARS Hana_INCLUDE_DIR
148 VERSION_VAR Hana_VERSION_STRING
149 )
150
151 if (Hana_FOUND)
152 set(Hana_INCLUDE_DIRS "${Hana_INCLUDE_DIR}")
153 endif()
154 endif()