Skip to content

Commit 4047ec6

Browse files
committed
Update websockets to c++20
1 parent f6932b1 commit 4047ec6

File tree

277 files changed

+45407
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

277 files changed

+45407
-0
lines changed

lib/websocketpp-c++20/.DS_Store

6 KB
Binary file not shown.

lib/websocketpp-c++20/BUILD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
#################
4+
## WebSocket++ ##
5+
#################
6+
cc_library(
7+
name = "websocketpp",
8+
hdrs = glob(["websocketpp/**/*.hpp"]),
9+
includes = ["."],
10+
deps = [
11+
"@asio//:asio",
12+
],
13+
)
Lines changed: 282 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,282 @@
1+
2+
############ Setup project and cmake
3+
# Minimum cmake requirement. We should require a quite recent
4+
# cmake for the dependency find macros etc. to be up to date.
5+
cmake_minimum_required (VERSION 2.8.8)
6+
7+
############ Paths
8+
9+
set (WEBSOCKETPP_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
10+
set (WEBSOCKETPP_INCLUDE ${WEBSOCKETPP_ROOT}/websocketpp)
11+
set (WEBSOCKETPP_BUILD_ROOT ${CMAKE_CURRENT_BINARY_DIR})
12+
set (WEBSOCKETPP_BIN ${WEBSOCKETPP_BUILD_ROOT}/bin)
13+
set (WEBSOCKETPP_LIB ${WEBSOCKETPP_BUILD_ROOT}/lib)
14+
15+
# CMake install step prefix. I assume linux users want the prefix to
16+
# be the default /usr or /usr/local so this is only adjusted on Windows.
17+
# This must be set prior to any call to project or it will not be read correctly.
18+
# - Windows: Build the INSTALL project in your solution file.
19+
# - Linux/OSX: make install.
20+
if (WIN32)
21+
set (CMAKE_INSTALL_PREFIX "${WEBSOCKETPP_ROOT}/install" CACHE PATH "")
22+
endif ()
23+
24+
############ Project name and version
25+
set (WEBSOCKETPP_MAJOR_VERSION 0)
26+
set (WEBSOCKETPP_MINOR_VERSION 8)
27+
set (WEBSOCKETPP_PATCH_VERSION 2)
28+
set (WEBSOCKETPP_VERSION ${WEBSOCKETPP_MAJOR_VERSION}.${WEBSOCKETPP_MINOR_VERSION}.${WEBSOCKETPP_PATCH_VERSION})
29+
30+
if(POLICY CMP0048)
31+
cmake_policy(GET CMP0048 _version_policy)
32+
endif()
33+
34+
if(_version_allowed STREQUAL NEW)
35+
project (websocketpp VERSION ${WEBSOCKETPP_VERSION})
36+
else()
37+
project (websocketpp)
38+
endif()
39+
40+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
41+
42+
set(INSTALL_INCLUDE_DIR include CACHE PATH "Installation directory for header files")
43+
if (WIN32 AND NOT CYGWIN)
44+
set (DEF_INSTALL_CMAKE_DIR cmake)
45+
else ()
46+
set (DEF_INSTALL_CMAKE_DIR lib/cmake/websocketpp)
47+
endif ()
48+
set (INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH "Installation directory for CMake files")
49+
50+
# Make relative paths absolute (needed later on)
51+
foreach (p INCLUDE CMAKE)
52+
set (var INSTALL_${p}_DIR)
53+
if (NOT IS_ABSOLUTE "${${var}}")
54+
set (${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
55+
endif ()
56+
endforeach ()
57+
58+
# Set CMake library search policy
59+
if (COMMAND cmake_policy)
60+
cmake_policy (SET CMP0003 NEW)
61+
cmake_policy (SET CMP0005 NEW)
62+
endif ()
63+
64+
# Disable unnecessary build types
65+
set (CMAKE_CONFIGURATION_TYPES "Release;RelWithDebInfo;Debug" CACHE STRING "Configurations" FORCE)
66+
67+
# Include our cmake macros
68+
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
69+
include (CMakeHelpers)
70+
71+
72+
############ Build customization
73+
74+
# Override from command line "CMake -D<OPTION>=TRUE/FALSE/0/1/ON/OFF"
75+
option (ENABLE_CPP11 "Build websocketpp with CPP11 features enabled." TRUE)
76+
option (BUILD_EXAMPLES "Build websocketpp examples." FALSE)
77+
option (BUILD_TESTS "Build websocketpp tests." FALSE)
78+
79+
if (BUILD_TESTS OR BUILD_EXAMPLES)
80+
81+
enable_testing ()
82+
83+
############ Compiler specific setup
84+
85+
set (WEBSOCKETPP_PLATFORM_LIBS "")
86+
set (WEBSOCKETPP_PLATFORM_TLS_LIBS "")
87+
set (WEBSOCKETPP_BOOST_LIBS "")
88+
89+
# VC9 and C++11 reasoning
90+
if (ENABLE_CPP11 AND MSVC AND MSVC90)
91+
message("* Detected Visual Studio 9 2008, disabling C++11 support.")
92+
set (ENABLE_CPP11 FALSE)
93+
endif ()
94+
95+
# Detect clang. Not officially reported by cmake.
96+
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-v" ERROR_VARIABLE CXX_VER_STDERR)
97+
if ("${CXX_VER_STDERR}" MATCHES ".*clang.*")
98+
set (CMAKE_COMPILER_IS_CLANGXX 1)
99+
endif ()
100+
101+
# C++11 defines
102+
if (ENABLE_CPP11)
103+
if (MSVC)
104+
add_definitions (-D_WEBSOCKETPP_CPP11_FUNCTIONAL_)
105+
add_definitions (-D_WEBSOCKETPP_CPP11_SYSTEM_ERROR_)
106+
add_definitions (-D_WEBSOCKETPP_CPP11_RANDOM_DEVICE_)
107+
add_definitions (-D_WEBSOCKETPP_CPP11_MEMORY_)
108+
else()
109+
add_definitions (-D_WEBSOCKETPP_CPP11_STL_)
110+
endif()
111+
endif ()
112+
113+
# Visual studio
114+
if (MSVC)
115+
set (WEBSOCKETPP_BOOST_LIBS system thread)
116+
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL /Gy /GF /Ox /Ob2 /Ot /Oi /MP /arch:SSE2 /fp:fast")
117+
set (CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG /INCREMENTAL:NO /OPT:REF /OPT:ICF")
118+
add_definitions (/W3 /wd4996 /wd4995 /wd4355)
119+
add_definitions (-DUNICODE -D_UNICODE)
120+
add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS)
121+
add_definitions (-DNOMINMAX)
122+
endif ()
123+
124+
# g++
125+
if (CMAKE_COMPILER_IS_GNUCXX)
126+
if (NOT APPLE)
127+
set (WEBSOCKETPP_PLATFORM_LIBS pthread rt)
128+
else()
129+
set (WEBSOCKETPP_PLATFORM_LIBS pthread)
130+
endif()
131+
set (WEBSOCKETPP_PLATFORM_TLS_LIBS ssl crypto)
132+
set (WEBSOCKETPP_BOOST_LIBS system thread)
133+
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
134+
if (NOT APPLE)
135+
add_definitions (-DNDEBUG -Wall -Wcast-align) # todo: should we use CMAKE_C_FLAGS for these?
136+
endif ()
137+
138+
# Try to detect version. Note: Not tested!
139+
execute_process (COMMAND ${CMAKE_CXX_COMPILER} "-dumpversion" OUTPUT_VARIABLE GCC_VERSION)
140+
if ("${GCC_VERSION}" STRGREATER "4.4.0")
141+
message("* C++11 support partially enabled due to GCC version ${GCC_VERSION}")
142+
set (WEBSOCKETPP_BOOST_LIBS system thread)
143+
endif ()
144+
endif ()
145+
146+
# clang
147+
if (CMAKE_COMPILER_IS_CLANGXX)
148+
if (NOT APPLE)
149+
set (WEBSOCKETPP_PLATFORM_LIBS pthread rt)
150+
else()
151+
set (WEBSOCKETPP_PLATFORM_LIBS pthread)
152+
endif()
153+
set (WEBSOCKETPP_PLATFORM_TLS_LIBS ssl crypto)
154+
set (WEBSOCKETPP_BOOST_LIBS system thread)
155+
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++0x -stdlib=libc++") # todo: is libc++ really needed here?
156+
if (NOT APPLE)
157+
add_definitions (-DNDEBUG -Wall -Wno-padded) # todo: should we use CMAKE_C_FLAGS for these?
158+
endif ()
159+
endif ()
160+
161+
# OSX, can override above.
162+
if (APPLE)
163+
add_definitions (-DNDEBUG -Wall)
164+
endif ()
165+
166+
if (BUILD_EXAMPLES)
167+
list (APPEND WEBSOCKETPP_BOOST_LIBS random)
168+
endif()
169+
170+
if (BUILD_TESTS)
171+
list (APPEND WEBSOCKETPP_BOOST_LIBS unit_test_framework)
172+
endif()
173+
174+
############ Dependencies
175+
176+
# Set BOOST_ROOT env variable or pass with cmake -DBOOST_ROOT=path.
177+
# BOOST_ROOT can also be defined by a previous run from cmake cache.
178+
if (NOT "$ENV{BOOST_ROOT_CPP11}" STREQUAL "")
179+
# Scons documentation for BOOST_ROOT_CPP11:
180+
# "look for optional second boostroot compiled with clang's libc++ STL library
181+
# this prevents warnings/errors when linking code built with two different
182+
# incompatible STL libraries."
183+
file (TO_CMAKE_PATH "$ENV{BOOST_ROOT_CPP11}" BOOST_ROOT)
184+
set (BOOST_ROOT ${BOOST_ROOT} CACHE PATH "BOOST_ROOT dependency path" FORCE)
185+
endif ()
186+
if ("${BOOST_ROOT}" STREQUAL "")
187+
file (TO_CMAKE_PATH "$ENV{BOOST_ROOT}" BOOST_ROOT)
188+
# Cache BOOST_ROOT for runs that do not define $ENV{BOOST_ROOT}.
189+
set (BOOST_ROOT ${BOOST_ROOT} CACHE PATH "BOOST_ROOT dependency path" FORCE)
190+
endif ()
191+
192+
message ("* Configuring Boost")
193+
message (STATUS "-- Using BOOST_ROOT")
194+
message (STATUS " " ${BOOST_ROOT})
195+
196+
if (MSVC)
197+
set (Boost_USE_MULTITHREADED TRUE)
198+
set (Boost_USE_STATIC_LIBS TRUE)
199+
else ()
200+
set (Boost_USE_MULTITHREADED FALSE)
201+
set (Boost_USE_STATIC_LIBS FALSE)
202+
endif ()
203+
204+
if (BOOST_STATIC)
205+
set (Boost_USE_STATIC_LIBS TRUE)
206+
endif ()
207+
208+
if (NOT Boost_USE_STATIC_LIBS)
209+
add_definitions (-DBOOST_TEST_DYN_LINK)
210+
endif ()
211+
212+
set (Boost_FIND_REQUIRED TRUE)
213+
set (Boost_FIND_QUIETLY TRUE)
214+
set (Boost_DEBUG FALSE)
215+
set (Boost_USE_MULTITHREADED TRUE)
216+
set (Boost_ADDITIONAL_VERSIONS "1.39.0" "1.40.0" "1.41.0" "1.42.0" "1.43.0" "1.44.0" "1.46.1") # todo: someone who knows better spesify these!
217+
218+
find_package (Boost 1.39.0 COMPONENTS "${WEBSOCKETPP_BOOST_LIBS}")
219+
220+
if (Boost_FOUND)
221+
# Boost is a project wide global dependency.
222+
include_directories (${Boost_INCLUDE_DIRS})
223+
link_directories (${Boost_LIBRARY_DIRS})
224+
225+
# Pretty print status
226+
message (STATUS "-- Include Directories")
227+
foreach (include_dir ${Boost_INCLUDE_DIRS})
228+
message (STATUS " " ${include_dir})
229+
endforeach ()
230+
message (STATUS "-- Library Directories")
231+
foreach (library_dir ${Boost_LIBRARY_DIRS})
232+
message (STATUS " " ${library_dir})
233+
endforeach ()
234+
message (STATUS "-- Libraries")
235+
foreach (boost_lib ${Boost_LIBRARIES})
236+
message (STATUS " " ${boost_lib})
237+
endforeach ()
238+
message ("")
239+
else ()
240+
message (FATAL_ERROR "Failed to find required dependency: boost")
241+
endif ()
242+
243+
find_package(OpenSSL)
244+
find_package(ZLIB)
245+
endif()
246+
247+
############ Add projects
248+
249+
# Add main library
250+
add_subdirectory (websocketpp)
251+
252+
# Add examples
253+
if (BUILD_EXAMPLES)
254+
include_subdirs ("examples")
255+
endif ()
256+
257+
# Add tests
258+
if (BUILD_TESTS)
259+
include_subdirs ("test")
260+
endif ()
261+
262+
print_used_build_config()
263+
264+
export (PACKAGE websocketpp)
265+
266+
include(CMakePackageConfigHelpers)
267+
configure_package_config_file(websocketpp-config.cmake.in
268+
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/websocketpp-config.cmake"
269+
PATH_VARS INSTALL_INCLUDE_DIR
270+
INSTALL_DESTINATION "${INSTALL_CMAKE_DIR}"
271+
NO_CHECK_REQUIRED_COMPONENTS_MACRO
272+
)
273+
write_basic_package_version_file("${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/websocketpp-configVersion.cmake"
274+
VERSION ${WEBSOCKETPP_VERSION}
275+
COMPATIBILITY ExactVersion)
276+
277+
# Install the websocketpp-config.cmake and websocketpp-configVersion.cmake
278+
install (FILES
279+
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/websocketpp-config.cmake"
280+
"${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/websocketpp-configVersion.cmake"
281+
DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)
282+

0 commit comments

Comments
 (0)