]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/CMakeLists.txt
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / CMakeLists.txt
CommitLineData
7c673cae
FG
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
5cmake_minimum_required(VERSION 3.1)
6list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
7
8
9##############################################################################
10# Setup project
11#
12# We parse the canonical version number located in <boost/hana/version.hpp>.
13# This is done to allow the library to be used without requiring a proper
14# installation during which the version would be written to this header.
15##############################################################################
16foreach(level MAJOR MINOR PATCH)
17 file(STRINGS include/boost/hana/version.hpp
18 _define_${level}
19 REGEX "#define BOOST_HANA_${level}_VERSION")
20 string(REGEX MATCH "([0-9]+)" _version_${level} "${_define_${level}}")
21endforeach()
22
23set(Boost.Hana_VERSION_STRING "${_version_MAJOR}.${_version_MINOR}.${_version_PATCH}")
24project(Boost.Hana VERSION ${Boost.Hana_VERSION_STRING} LANGUAGES CXX)
25
26# Perform checks to make sure we support the current compiler
27include(CheckCxxCompilerSupport)
28
29
30##############################################################################
31# Setup the 'hana' header-only library target.
32##############################################################################
33add_library(hana INTERFACE)
34target_include_directories(hana INTERFACE include)
35
36
37##############################################################################
38# Setup CMake options
39##############################################################################
40option(BOOST_HANA_ENABLE_WERROR "Fail and stop if a warning is triggered." OFF)
41option(BOOST_HANA_ENABLE_MEMCHECK "Run the unit tests and examples under Valgrind if it is found." OFF)
42option(BOOST_HANA_ENABLE_CONCEPT_CHECKS "Enable concept checking in the interface methods." ON)
43option(BOOST_HANA_ENABLE_DEBUG_MODE "Enable Hana's debug mode." OFF)
44
45option(BOOST_HANA_ENABLE_STRING_UDL
46"Enable the GNU extension allowing the special string literal operator\
47 template, which enables the _s suffix for creating compile-time strings." ON)
48
49option(BOOST_HANA_ENABLE_EXCEPTIONS
50"Build with exceptions enabled. Note that Hana does not make use of exceptions,\
51 but this switch can be disabled when building the tests to assess that it is\
52 really the case." ON)
53
54
55##############################################################################
56# Setup compiler flags (more can be set on a per-target basis or in subdirectories)
57##############################################################################
58include(CheckCXXCompilerFlag)
59macro(boost_hana_append_flag testname flag)
60 check_cxx_compiler_flag(${flag} ${testname})
61 if (${testname})
62 add_compile_options(${flag})
63 endif()
64endmacro()
65
66# Compiler flags controlled by CMake options above
67if (BOOST_HANA_ENABLE_WERROR)
68 boost_hana_append_flag(BOOST_HANA_HAS_WERROR -Werror)
69 boost_hana_append_flag(BOOST_HANA_HAS_WX -WX)
70endif()
71
72if (NOT BOOST_HANA_ENABLE_CONCEPT_CHECKS)
73 add_definitions(-DBOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS)
74endif()
75
76if (BOOST_HANA_ENABLE_DEBUG_MODE)
77 add_definitions(-DBOOST_HANA_CONFIG_ENABLE_DEBUG_MODE)
78endif()
79
80if (BOOST_HANA_ENABLE_STRING_UDL)
81 add_definitions(-DBOOST_HANA_CONFIG_ENABLE_STRING_UDL)
82 # GCC pretends to have the flag, but produces a "unrecognized command line option"
83 # warning when we use it.
84 if (NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
85 boost_hana_append_flag(BOOST_HANA_HAS_WNO_GNU_STRING_UDL
86 -Wno-gnu-string-literal-operator-template)
87 endif()
88endif()
89
90if (NOT BOOST_HANA_ENABLE_EXCEPTIONS)
91 boost_hana_append_flag(BOOST_HANA_HAS_FNO_EXCEPTIONS -fno-exceptions)
92endif()
93
94# Other compiler flags
95boost_hana_append_flag(BOOST_HANA_HAS_FDIAGNOSTICS_COLOR -fdiagnostics-color)
96boost_hana_append_flag(BOOST_HANA_HAS_FTEMPLATE_BACKTRACE_LIMIT -ftemplate-backtrace-limit=0)
97boost_hana_append_flag(BOOST_HANA_HAS_PEDANTIC -pedantic)
98boost_hana_append_flag(BOOST_HANA_HAS_STDCXX1Y -std=c++1y)
99boost_hana_append_flag(BOOST_HANA_HAS_QUNUSED_ARGUMENTS -Qunused-arguments)
100boost_hana_append_flag(BOOST_HANA_HAS_W -W)
101boost_hana_append_flag(BOOST_HANA_HAS_WALL -Wall)
102boost_hana_append_flag(BOOST_HANA_HAS_WEXTRA -Wextra)
103boost_hana_append_flag(BOOST_HANA_HAS_WNO_UNUSED_LOCAL_TYPEDEFS -Wno-unused-local-typedefs)
104boost_hana_append_flag(BOOST_HANA_HAS_WWRITE_STRINGS -Wwrite-strings)
105
106
107##############################################################################
108# Setup include paths. More include paths can be added in subdirectories.
109##############################################################################
110include_directories(${Boost.Hana_SOURCE_DIR}/include)
111
112find_package(Boost 1.59)
113if (Boost_FOUND)
114 include_directories(${Boost_INCLUDE_DIRS})
115else()
116 message(WARNING
117 "The Boost library headers were not found; targets depending "
118 "on Boost won't be available.")
119endif()
120
121
122##############################################################################
123# Setup custom functions to ease the creation of targets
124##############################################################################
125# boost_hana_target_name_for(<output variable> <source file> [ext])
126#
127# Return the target name associated to a source file. If the path of the
128# source file relative from the root of Hana is `path/to/source/file.ext`,
129# the target name associated to it will be `path.to.source.file`.
130#
131# The extension of the file should be specified as a last argument. If no
132# extension is specified, the `.cpp` extension is assumed.
133function(boost_hana_target_name_for out file)
134 if (NOT ARGV2)
135 set(_extension ".cpp")
136 else()
137 set(_extension "${ARGV2}")
138 endif()
139
140 file(RELATIVE_PATH _relative ${Boost.Hana_SOURCE_DIR} ${file})
141 string(REPLACE "${_extension}" "" _name ${_relative})
142 string(REGEX REPLACE "/" "." _name ${_name})
143 set(${out} "${_name}" PARENT_SCOPE)
144endfunction()
145
146# boost_hana_add_test(<name> <command> [<arg>...])
147#
148# Creates a test called `name`, which runs the given `command` with the given
149# `arg`uments. However, if `BOOST_HANA_ENABLE_MEMCHECK` is set to `ON`, the
150# test will run the provided command under the memory checker.
151if (BOOST_HANA_ENABLE_MEMCHECK)
152 find_package(Valgrind REQUIRED)
153 function(boost_hana_add_test name)
154 add_test(${name} ${Valgrind_EXECUTABLE} --leak-check=full --error-exitcode=1 ${ARGN})
155 endfunction()
156else()
157 function(boost_hana_add_test name)
158 add_test(${name} ${ARGN})
159 endfunction()
160endif()
161
162
163##############################################################################
164# Setup the `check` target to build and then run all the tests and examples.
165##############################################################################
166add_custom_target(check
167 COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
168 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
169 COMMENT "Build and then run all the tests and examples.")
170
171
172##############################################################################
173# Setup subdirectories
174##############################################################################
175enable_testing()
176add_subdirectory(benchmark)
177add_subdirectory(doc)
178add_subdirectory(example)
179add_subdirectory(experimental)
180add_subdirectory(test)
181
182
183##############################################################################
184# Setup the 'install' target.
185# This copies the whole content of include/ to ${CMAKE_INSTALL_PREFIX}.
186##############################################################################
187install(DIRECTORY include/boost DESTINATION include
188 PATTERN ".DS_Store" EXCLUDE)
189
190# We also install an optional pkg-config file.
191configure_file(cmake/hana.pc.in hana.pc @ONLY)
192install(FILES ${CMAKE_CURRENT_BINARY_DIR}/hana.pc DESTINATION lib/pkgconfig)