forked from boostorg/beast
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
144 lines (122 loc) · 5.31 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Part of Beast
cmake_minimum_required (VERSION 3.2)
project (Beast)
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
if (MSVC)
# /wd4244 /wd4127
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4244 /MP /W4 /wd4100 /bigobj /D _WIN32_WINNT=0x0601 /D _SCL_SECURE_NO_WARNINGS=1 /D _CRT_SECURE_NO_WARNINGS=1")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ob2 /Oi /Ot /GL /MT")
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Oi /Ot /MT")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
set (CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG")
# for RelWithDebInfo builds, disable incremental linking
# since CMake sets it ON by default for that build type and it
# causes warnings
string (REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" replacement_flags
${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO})
set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO ${replacement_flags})
else()
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
find_package(Boost REQUIRED COMPONENTS coroutine context thread filesystem program_options system)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
link_directories(${Boost_LIBRARY_DIR})
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wpedantic -Wno-unused-parameter")
endif()
add_definitions ("-DBOOST_COROUTINES_NO_DEPRECATION_WARNING")
if (APPLE AND NOT DEFINED ENV{OPENSSL_ROOT_DIR})
find_program(HOMEBREW brew)
if (NOT HOMEBREW STREQUAL "HOMEBREW-NOTFOUND")
execute_process(COMMAND brew --prefix openssl
OUTPUT_VARIABLE OPENSSL_ROOT_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)
endif()
endif()
find_package(OpenSSL)
if (MINGW)
link_libraries(${Boost_LIBRARIES} ws2_32 mswsock)
endif()
if ("${VARIANT}" STREQUAL "coverage")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov")
elseif ("${VARIANT}" STREQUAL "asan")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
elseif ("${VARIANT}" STREQUAL "usan")
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-omit-frame-pointer")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
set(CMAKE_BUILD_TYPE RELWITHDEBINFO)
elseif ("${VARIANT}" STREQUAL "debug")
set(CMAKE_BUILD_TYPE DEBUG)
elseif ("${VARIANT}" STREQUAL "release")
set(CMAKE_BUILD_TYPE RELEASE)
endif()
function(DoGroupSources curdir rootdir folder)
file(GLOB children RELATIVE ${PROJECT_SOURCE_DIR}/${curdir} ${PROJECT_SOURCE_DIR}/${curdir}/*)
foreach(child ${children})
if(IS_DIRECTORY ${PROJECT_SOURCE_DIR}/${curdir}/${child})
DoGroupSources(${curdir}/${child} ${rootdir} ${folder})
elseif(${child} STREQUAL "CMakeLists.txt")
source_group("" FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
else()
string(REGEX REPLACE ^${rootdir} ${folder} groupname ${curdir})
string(REPLACE "/" "\\" groupname ${groupname})
source_group(${groupname} FILES ${PROJECT_SOURCE_DIR}/${curdir}/${child})
endif()
endforeach()
endfunction()
function(GroupSources curdir folder)
DoGroupSources(${curdir} ${curdir} ${folder})
endfunction()
include_directories (extras)
include_directories (include)
set(ZLIB_SOURCES
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/crc32.h
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/deflate.h
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/inffast.h
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/inffixed.h
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/inflate.h
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/inftrees.h
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/trees.h
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/zlib.h
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/zutil.h
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/adler32.c
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/compress.c
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/crc32.c
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/deflate.c
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/infback.c
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/inffast.c
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/inflate.c
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/inftrees.c
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/trees.c
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/uncompr.c
${PROJECT_SOURCE_DIR}/test/zlib/zlib-1.2.8/zutil.c
)
file(GLOB_RECURSE BEAST_INCLUDES
${PROJECT_SOURCE_DIR}/include/beast/*.hpp
${PROJECT_SOURCE_DIR}/include/beast/*.ipp
)
file(GLOB_RECURSE EXTRAS_INCLUDES
${PROJECT_SOURCE_DIR}/extras/beast/*.hpp
${PROJECT_SOURCE_DIR}/extras/beast/*.ipp
)
add_subdirectory (examples)
if (NOT OPENSSL_FOUND)
message("OpenSSL not found. Not building examples/ssl")
else()
add_subdirectory (examples/ssl)
endif()
add_subdirectory (test)
add_subdirectory (test/core)
add_subdirectory (test/http)
add_subdirectory (test/websocket)
add_subdirectory (test/zlib)