-
Notifications
You must be signed in to change notification settings - Fork 36
/
CMakeLists.txt
174 lines (139 loc) · 5.85 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
cmake_minimum_required(VERSION 3.0)
project (bredis)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include (CTest)
enable_testing()
add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
add_definitions(-DBOOST_COROUTINES_NO_DEPRECATION_WARNING)
add_definitions(-DBOOST_ASIO_NO_DEPRECATED)
#add_definitions(-DBREDIS_DEBUG)
find_package(
Boost
COMPONENTS
chrono
coroutine
filesystem
regex
system
thread
program_options
REQUIRED
)
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
execute_process(COMMAND
${CMAKE_CXX_COMPILER} -dumpversion
OUTPUT_VARIABLE GCC_VERSION)
string(STRIP ${GCC_VERSION} GCC_VERSION)
MESSAGE(STATUS "gcc version: [" ${GCC_VERSION} "]")
# this works on gentoo, but not on travis/ubuntu, let's hard-code the value
#execute_process(COMMAND
# "which" "gcov-${GCC_VERSION}"
# OUTPUT_VARIABLE GCOV_TOOL)
#MESSAGE(STATUS "gcov: [" ${GCOV_TOOL} "]")
#string(STRIP ${GCOV_TOOL} GCOV_TOOL)
#MESSAGE(STATUS "gcov(fixed): [" ${GCOV_TOOL} "]")
set(GCOV_TOOL "gcov-5")
add_custom_target("coverage"
COMMAND "lcov" --directory . --zerocounters
COMMAND ctest
COMMAND "lcov" --directory . --capture --output-file coverage.info --gcov-tool ${GCOV_TOOL}
COMMAND "lcov" --remove coverage.info "'/t/*'" "'/boost_1_63_0/*'" "'/usr/*'" --output-file coverage.info.cleaned
COMMAND "rm" coverage.info
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target("coverage-report"
COMMAND "genhtml" -o coverage coverage.info.cleaned
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
DEPENDS "coverage"
)
endif()
include_directories(${bredis_SOURCE_DIR}/include ${Boost_INCLUDE_DIRS})
MESSAGE(STATUS "boost inc: " ${Boost_INCLUDE_DIRS})
MESSAGE(STATUS "boost libs: " ${Boost_LIBRARIES})
add_library(catch_lib t/tests-main.cpp)
if(WIN32)
set(Boost_USE_MULTITHREADED ON)
set(LINK_DEPENDENCIES ${Boost_LIBRARIES} catch_lib)
add_definitions(-DBOOST_ALL_DYN_LINK -DBOOST_THREAD_USE_LIB -D_WIN32_WINNT=0x0501)
else()
#add_definitions(-Wall -Wextra -pedantic -Werror)
add_definitions(-Wall -Wextra -pedantic)
#add_definitions(-fsanitize=undefined -fsanitize=address -fno-omit-frame-pointer)
set(LINK_DEPENDENCIES pthread ${Boost_LIBRARIES} catch_lib) # asan ubsan
endif()
if ((Boost_MAJOR_VERSION GREATER_EQUAL 1) AND (Boost_MINOR_VERSION GREATER_EQUAL 70))
set(BOOST_VERSION_OK true)
else()
set(BOOST_VERSION_OK false)
endif()
MESSAGE(STATUS "BOOST_VERSION_OK ${BOOST_VERSION_OK}")
add_subdirectory(examples)
add_executable(t-05-protocol t/05-protocol.cpp)
target_link_libraries(t-05-protocol ${LINK_DEPENDENCIES})
add_test("t-05-protocol" t-05-protocol)
add_executable(t-06-fragmented-buffer t/06-fragmented-buffer.cpp)
target_link_libraries(t-06-fragmented-buffer ${LINK_DEPENDENCIES})
add_test("t-06-fragmented-buffer" t-06-fragmented-buffer)
add_executable(t-07-extract t/07-extract.cpp)
target_link_libraries(t-07-extract ${LINK_DEPENDENCIES})
add_test("t-07-extract" t-07-extract)
add_executable(t-08-markers t/08-markers.cpp)
target_link_libraries(t-08-markers ${LINK_DEPENDENCIES})
add_test("t-07-extract" t-08-markers)
add_executable(t-10-ping t/10-ping.cpp)
target_link_libraries(t-10-ping ${LINK_DEPENDENCIES})
add_test("t-10-ping" t-10-ping)
add_executable(t-11-multi-ping t/11-multi-ping.cpp)
target_link_libraries(t-11-multi-ping ${LINK_DEPENDENCIES})
add_test("t-11-multi-ping" t-11-multi-ping)
add_executable(t-12-basic-types t/12-basic-types.cpp)
target_link_libraries(t-12-basic-types ${LINK_DEPENDENCIES})
add_test("t-12-basic-types" t-12-basic-types)
add_executable(t-13-protol-error t/13-protol-error.cpp)
target_link_libraries(t-13-protol-error ${LINK_DEPENDENCIES})
add_test("t-13-protol-error" t-13-protol-error)
if(NOT WIN32)
add_executable(t-14-uds t/14-uds.cpp)
target_link_libraries(t-14-uds ${LINK_DEPENDENCIES})
add_test("t-14-uds" t-14-uds)
endif()
add_executable(t-15-cancellation t/15-cancellation.cpp)
target_link_libraries(t-15-cancellation ${LINK_DEPENDENCIES})
add_test("t-15-cancellation" t-15-cancellation)
add_executable(t-16-close-connection t/16-close-connection.cpp)
target_link_libraries(t-16-close-connection ${LINK_DEPENDENCIES})
add_test("t-16-close-connection" t-16-close-connection)
add_executable(t-17-sync t/17-sync.cpp)
target_link_libraries(t-17-sync ${LINK_DEPENDENCIES})
add_test("t-17-sync" t-17-sync)
add_executable(t-18-subscription t/18-subscription.cpp)
target_link_libraries(t-18-subscription ${LINK_DEPENDENCIES})
add_test("t-18-subscription" t-18-subscription)
add_executable(t-19-transaction t/19-transaction.cpp)
target_link_libraries(t-19-transaction ${LINK_DEPENDENCIES})
add_test("t-19-transaction" t-19-transaction)
if(BOOST_VERSION_OK)
add_executable(t-20-promise t/20-promise.cpp)
target_link_libraries(t-20-promise ${LINK_DEPENDENCIES})
add_test("t-20-promise" t-20-promise)
endif()
# seems boost is periodically broken. Please, send a fixing PR if u know how
if ((Boost_MAJOR_VERSION GREATER_EQUAL 1) AND (Boost_MINOR_VERSION GREATER_EQUAL 74))
add_executable(t-21-coroutine t/21-coroutine.cpp)
target_link_libraries(t-21-coroutine ${LINK_DEPENDENCIES})
add_test("t-21-coroutine" t-21-coroutine)
endif()
add_executable(t-22-ping_drop-policy t/22-ping_drop-policy.cpp)
target_link_libraries(t-22-ping_drop-policy ${LINK_DEPENDENCIES})
add_test("t-22-ping_drop-policy" t-22-ping_drop-policy)
add_executable(t-23-stream t/23-stream.cpp)
target_link_libraries(t-23-stream ${LINK_DEPENDENCIES})
add_test("t-23-stream" t-23-stream)
if(BOOST_VERSION_OK)
add_executable(t-24-dynbuff t/24-dynbuff.cpp)
target_link_libraries(t-24-dynbuff ${LINK_DEPENDENCIES})
add_test("t-24-dynbuff" t-24-dynbuff)
endif()