]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/callable_traits/CMakeLists.txt
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / callable_traits / CMakeLists.txt
1
2 # Copyright Louis Dionne 2015
3 # Modified Work Copyright Barrett Adair 2015-2017
4 # Distributed under the Boost Software License, Version 1.0.
5 # (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
6
7 cmake_minimum_required(VERSION 3.0)
8 project(callable_traits CXX)
9 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
10 enable_testing()
11
12 if(BUILD_CXX_STD)
13 else()
14 # Defaults to C++14 if not set:
15 set(BUILD_CXX_STD 14)
16 endif()
17
18 set (CMAKE_CXX_STANDARD ${callable_traits_CXX_STD})
19
20 # Setting up CMake options and compiler flags (more flags can be set on a per-target basis or in subdirectories)
21
22 include(CheckCXXCompilerFlag)
23 macro(callable_traits_append_flag testname flag)
24 check_cxx_compiler_flag(${flag} ${testname})
25 if (${testname})
26 add_compile_options(${flag})
27 endif()
28 endmacro()
29
30 if(NOT MSVC OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
31
32 # enable all warnings and treat them all as errors
33 callable_traits_append_flag(callable_traits_HAS_WERROR -Werror)
34 callable_traits_append_flag(callable_traits_HAS_WX -WX)
35 callable_traits_append_flag(callable_traits_HAS_W -W)
36 callable_traits_append_flag(callable_traits_HAS_WALL -Wall)
37 callable_traits_append_flag(callable_traits_HAS_WEXTRA -Wextra)
38 endif()
39
40 if(MSVC)
41
42 # MSVC/Clang-cl builds need -Qunused-arguments
43 callable_traits_append_flag(callable_traits_HAS_QUNUSED_ARGUMENTS -Qunused-arguments)
44 else()
45
46 # for better template error debugging
47 callable_traits_append_flag(callable_traits_HAS_FTEMPLATE_BACKTRACE_LIMIT -ftemplate-backtrace-limit=0)
48
49 # enforce strict standards compliance
50 callable_traits_append_flag(callable_traits_HAS_PEDANTIC -pedantic)
51
52 # use the most recent C++ standard available
53 callable_traits_append_flag(callable_traits_HAS_STDCXX0x -std=c++0x)
54 callable_traits_append_flag(callable_traits_HAS_STDCXX1y -std=c++1y)
55 callable_traits_append_flag(callable_traits_HAS_STDCXX1z -std=c++1z)
56 endif()
57
58 # transactional memory - currently only available in GCC 6 and later
59 if(NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
60 callable_traits_append_flag(callable_traits_HAS_FGNU_TM -fgnu-tm)
61 endif()
62
63 #
64 #find_package(Doxygen)
65 ##find_package(Meta)
66 #find_package(PythonInterp 2.7)
67 #find_package(Ruby 2.1)
68
69 ##############################################################################
70 # callable_traits_target_name_for(<output variable> <source file> [ext])
71 # Returns the target name associated to a source file. If the path of the
72 # source file relative from the root of callable_traits is `path/to/source/file.ext`,
73 # the target name associated to it will be `path.to.source.file`.
74 #
75 # The extension of the file should be specified as a last argument. If no
76 # extension is specified, the `.cpp` extension is assumed.
77 ##############################################################################
78
79 function(callable_traits_target_name_for out file)
80 if (NOT ARGV2)
81 set(_extension ".cpp")
82 else()
83 set(_extension "${ARGV2}")
84 endif()
85
86 file(RELATIVE_PATH _relative ${callable_traits_SOURCE_DIR} ${file})
87 string(REPLACE "${_extension}" "" _name ${_relative})
88 string(REGEX REPLACE "/" "." _name ${_name})
89 set(${out} "${_name}" PARENT_SCOPE)
90 endfunction()
91
92 ##############################################################################
93 # callable_traits_add_test(<name> <command> [<arg>...])
94 # Creates a test called `name`, which runs the given `command` with the given args.
95 ##############################################################################
96
97 function(callable_traits_add_test name)
98 if (callable_traits_ENABLE_MEMCHECK)
99 add_test(${name} ${Valgrind_EXECUTABLE} --leak-check=full --error-exitcode=1 ${ARGN})
100 else()
101 add_test(${name} ${ARGN})
102 endif()
103 endfunction()
104
105 ##############################################################################
106 # Setup the `check` target to build and then run all the tests and examples.
107 ##############################################################################
108
109
110 add_custom_target(check
111 COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
112 WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
113 COMMENT "Build and then run all the tests and examples.")
114
115 add_subdirectory(example)
116 add_subdirectory(test)
117
118 ##############################################################################
119 # Setup the 'install' target and the package config file.
120 ##############################################################################
121 add_library(callable_traits INTERFACE)
122 target_include_directories(callable_traits INTERFACE
123 "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
124 $<INSTALL_INTERFACE:include>)
125 install(TARGETS callable_traits EXPORT CallableTraitsConfig)
126 install(EXPORT CallableTraitsConfig DESTINATION lib/cmake/CallableTraits)
127 install(DIRECTORY include/boost DESTINATION include FILES_MATCHING PATTERN "*.hpp")