]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/beast/CMakeLists.txt
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / boost / libs / beast / CMakeLists.txt
1 if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
2
3 # Generated by `boostdep --cmake beast`
4 # Copyright 2020, 2021 Peter Dimov
5 # Distributed under the Boost Software License, Version 1.0.
6 # https://www.boost.org/LICENSE_1_0.txt
7
8 cmake_minimum_required(VERSION 3.8...3.20)
9
10 project(boost_beast VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
11
12 add_library(boost_beast INTERFACE)
13 add_library(Boost::beast ALIAS boost_beast)
14
15 target_include_directories(boost_beast INTERFACE include)
16
17 target_link_libraries(boost_beast
18 INTERFACE
19 Boost::asio
20 Boost::assert
21 Boost::bind
22 Boost::config
23 Boost::container
24 Boost::core
25 Boost::endian
26 Boost::intrusive
27 Boost::logic
28 Boost::mp11
29 Boost::optional
30 Boost::smart_ptr
31 Boost::static_assert
32 Boost::system
33 Boost::throw_exception
34 Boost::type_traits
35 Boost::utility
36 Boost::winapi
37 )
38
39 target_compile_features(boost_beast INTERFACE cxx_std_11)
40
41 else()
42
43 #
44 # Copyright (c) 2016-2017 Vinnie Falco (vinnie dot falco at gmail dot com)
45 #
46 # Distributed under the Boost Software License, Version 1.0. (See accompanying
47 # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
48 #
49 # Official repository: https://github.com/boostorg/beast
50 #
51
52 cmake_minimum_required (VERSION 3.5.1)
53
54 if (POLICY CMP0074)
55 cmake_policy (SET CMP0074 NEW)
56 endif()
57
58 #-------------------------------------------------------------------------------
59
60 function (DoGroupSources curdir rootdir folder)
61 file (GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*)
62 foreach (child ${children})
63 if (IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
64 DoGroupSources (${curdir}/${child} ${rootdir} ${folder})
65 elseif (${child} STREQUAL "CMakeLists.txt")
66 source_group("" FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
67 else()
68 string (REGEX REPLACE ^${rootdir} ${folder} groupname ${curdir})
69 string (REPLACE "/" "\\" groupname ${groupname})
70 source_group (${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
71 endif()
72 endforeach()
73 endfunction()
74
75 function (GroupSources curdir folder)
76 DoGroupSources (${curdir} ${curdir} ${folder})
77 endfunction()
78
79 #-------------------------------------------------------------------------------
80 #
81 # Beast
82 #
83 #-------------------------------------------------------------------------------
84
85 project (Beast VERSION 330)
86
87 set_property (GLOBAL PROPERTY USE_FOLDERS ON)
88 option (Beast_BUILD_EXAMPLES "Build examples" ON)
89 option (Beast_BUILD_TESTS "Build tests" ON)
90 option (Beast_ENABLE_HANDLER_TRACKING "Define BOOST_ASIO_ENABLE_HANDLER_TRACKING when building libraries" OFF)
91 option (Boost_USE_STATIC_LIBS "Use Static Boost libraries" ON)
92
93 if (MSVC)
94 set (CMAKE_VERBOSE_MAKEFILE FALSE)
95
96 add_definitions (
97 -D_WIN32_WINNT=0x0601
98 -D_SCL_SECURE_NO_WARNINGS=1
99 -D_CRT_SECURE_NO_WARNINGS=1
100 -D_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING
101 -D_SILENCE_CXX17_ADAPTOR_TYPEDEFS_DEPRECATION_WARNING
102 )
103
104 add_compile_options(
105 /bigobj # large object file format
106 /permissive- # strict C++
107 #/wd4503 # decorated name length exceeded, name was truncated
108 /W4 # enable all warnings
109 /MP # Multi-processor compilation
110 )
111
112 set (Boost_USE_STATIC_RUNTIME ON)
113
114 set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
115 set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ob2 /Oi /Ot /GL /MT")
116 set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Oi /Ot /MT")
117
118 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
119 set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
120
121 # for RelWithDebInfo builds, disable incremental linking
122 # since CMake sets it ON by default for that build type and it
123 # causes warnings
124 #
125 string (REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" replacement_flags
126 ${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
127 set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${replacement_flags})
128
129 else()
130 set (THREADS_PREFER_PTHREAD_FLAG ON)
131 find_package (Threads)
132 link_libraries(Threads::Threads)
133
134
135 set( CMAKE_CXX_FLAGS
136 "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wpedantic -Wno-unused-parameter")
137
138 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
139 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wrange-loop-analysis")
140 endif ()
141 endif()
142
143 # Must come before Boost includes, otherwise the
144 # IDE sees the wrong file due to boost/ symlinks.
145 include_directories (include)
146
147 #-------------------------------------------------------------------------------
148 #
149 # OpenSSL
150 #
151 #-------------------------------------------------------------------------------
152
153 if (APPLE AND NOT DEFINED ENV{OPENSSL_ROOT_DIR})
154 find_program(HOMEBREW brew)
155 if (NOT HOMEBREW STREQUAL "HOMEBREW-NOTFOUND")
156 execute_process(COMMAND brew --prefix openssl
157 OUTPUT_VARIABLE OPENSSL_ROOT_DIR
158 OUTPUT_STRIP_TRAILING_WHITESPACE)
159 endif()
160 endif()
161
162 find_package(OpenSSL)
163 if (NOT MSVC)
164 link_libraries(${OPENSSL_LIBRARIES})
165 endif()
166
167 #-------------------------------------------------------------------------------
168 #
169 # Boost
170 #
171 #-------------------------------------------------------------------------------
172
173 get_filename_component (BOOST_ROOT ../../ ABSOLUTE)
174
175 # VFALCO I want static but "b2 stage" builds a minimal set which excludes static
176 add_definitions (-DBOOST_ALL_STATIC_LINK=1)
177
178 add_definitions (-DBOOST_ASIO_NO_DEPRECATED=1)
179 add_definitions (-DBOOST_ASIO_DISABLE_BOOST_ARRAY=1)
180 add_definitions (-DBOOST_ASIO_DISABLE_BOOST_BIND=1)
181 add_definitions (-DBOOST_ASIO_DISABLE_BOOST_DATE_TIME=1)
182 add_definitions (-DBOOST_ASIO_DISABLE_BOOST_REGEX=1)
183 add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING=1)
184
185 if (MSVC)
186 include_directories (${BOOST_ROOT})
187 link_libraries( bcrypt.lib )
188 else()
189 set(BOOST_INCLUDEDIR ${BOOST_ROOT})
190 set(BOOST_LIBRARYDIR ${BOOST_ROOT}/stage/lib)
191 find_package(Boost COMPONENTS coroutine filesystem system thread REQUIRED)
192 link_libraries(Boost::coroutine Boost::filesystem Boost::system Boost::thread)
193 endif()
194
195 link_directories(${BOOST_ROOT}/stage/lib)
196
197 if (MINGW)
198 link_libraries(ws2_32 mswsock)
199 endif()
200
201 #-------------------------------------------------------------------------------
202
203 if ("${VARIANT}" STREQUAL "coverage")
204 if (MSVC)
205 else()
206 set (CMAKE_BUILD_TYPE DEBUG)
207 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse4.2 --coverage")
208 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
209 endif()
210
211 elseif ("${VARIANT}" STREQUAL "ubasan")
212 if (MSVC)
213 else()
214 set (CMAKE_BUILD_TYPE RELWITHDEBINFO)
215 set (CMAKE_CXX_FLAGS
216 "${CMAKE_CXX_FLAGS} -DBOOST_BEAST_NO_SLOW_TESTS=1 -msse4.2 -funsigned-char -fno-omit-frame-pointer -fsanitize=address,undefined -fno-sanitize-recover=address,undefined -fsanitize-blacklist=${PROJECT_SOURCE_DIR}/tools/blacklist.supp")
217 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address,undefined -fno-sanitize-recover=address,undefined")
218 endif()
219
220 elseif ("${VARIANT}" STREQUAL "debug")
221 set (CMAKE_BUILD_TYPE DEBUG)
222
223 elseif ("${VARIANT}" STREQUAL "release")
224 set (CMAKE_BUILD_TYPE RELEASE)
225
226 endif()
227
228 #-------------------------------------------------------------------------------
229 #
230 # Static Libraries
231 #
232 #-------------------------------------------------------------------------------
233
234 add_definitions (-DBOOST_ASIO_SEPARATE_COMPILATION=1)
235 add_definitions (-DBOOST_BEAST_SEPARATE_COMPILATION=1)
236
237 GroupSources (test "/")
238
239 add_library (
240 lib-asio STATIC
241 test/lib_asio.cpp
242 )
243 if(Beast_ENABLE_HANDLER_TRACKING)
244 target_compile_definitions(lib-asio
245 PUBLIC BOOST_ASIO_ENABLE_HANDLER_TRACKING=1)
246 endif()
247
248 set_property(TARGET lib-asio PROPERTY FOLDER "static-libs")
249
250 add_library (
251 lib-asio-ssl STATIC
252 test/lib_asio_ssl.cpp
253 )
254
255 set_property(TARGET lib-asio-ssl PROPERTY FOLDER "static-libs")
256
257 add_library (
258 lib-beast STATIC
259 test/lib_beast.cpp
260 )
261
262 set_property(TARGET lib-beast PROPERTY FOLDER "static-libs")
263
264 target_link_libraries(lib-beast lib-asio)
265
266 #-------------------------------------------------------------------------------
267 #
268 # Tests and examples
269 #
270
271 include_directories (.)
272
273 if (OPENSSL_FOUND)
274 include_directories (${OPENSSL_INCLUDE_DIR})
275 endif()
276
277 file (GLOB_RECURSE BOOST_BEAST_FILES
278 ${PROJECT_SOURCE_DIR}/include/boost/beast/*.hpp
279 ${PROJECT_SOURCE_DIR}/include/boost/beast/*.ipp
280 )
281
282 file (GLOB_RECURSE BOOST_BEAST_EXPERIMENTAL_FILES
283 ${PROJECT_SOURCE_DIR}/include/boost/beast/_experimental/*.hpp
284 ${PROJECT_SOURCE_DIR}/include/boost/beast/_experimental/*.ipp
285 )
286
287 file (GLOB_RECURSE COMMON_FILES
288 ${PROJECT_SOURCE_DIR}/example/common/*.hpp
289 )
290
291 if (Beast_BUILD_EXAMPLES AND
292 (NOT "${VARIANT}" STREQUAL "coverage") AND
293 (NOT "${VARIANT}" STREQUAL "ubasan"))
294 add_subdirectory (example)
295 endif()
296
297 if (Beast_BUILD_TESTS)
298 add_subdirectory (test)
299 endif()
300
301 endif()