-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
254 lines (219 loc) · 6.3 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
cmake_minimum_required(VERSION 2.8)
project(imapdl CXX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8")
message(FATAL_ERROR "You need at least version 4.8 when compiling with GCC")
endif()
endif()
include (${CMAKE_SOURCE_DIR}/cmake/coverage.cmake)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedefs")
endif()
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-const-variable")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/ragel")
find_package(RAGEL 6.6 REQUIRED)
# for out of source tree builds - when ragel generated files
# are not in the same dir as the source (include "foo.h"->foo.h can't be found)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(Boost 1.55
COMPONENTS
system # needed by filesystem, log
filesystem
regex
unit_test_framework
program_options
serialization
log
log_setup
# needed by log
thread
#
locale
regex
REQUIRED)
include_directories(
${Boost_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/libixxx
${CMAKE_CURRENT_SOURCE_DIR}/libbuffer
)
RAGEL_TARGET(imap_client_parser imap/client_parser.rl ${CMAKE_CURRENT_BINARY_DIR}/imap_client_parser.cc COMPILE_FLAGS -I${CMAKE_CURRENT_SOURCE_DIR})
RAGEL_TARGET(imap_server_parser imap/server_parser.rl ${CMAKE_CURRENT_BINARY_DIR}/imap_server_parser.cc COMPILE_FLAGS -I${CMAKE_CURRENT_SOURCE_DIR})
RAGEL_TARGET(mime_base64_decoder mime/base64_decoder.rl ${CMAKE_CURRENT_BINARY_DIR}/mime_base64_decoder.cc)
RAGEL_TARGET(mime_base64_decoder_main mime/base64_decoder_main.rl ${CMAKE_CURRENT_BINARY_DIR}/mime_base64_decoder_main.cc)
RAGEL_TARGET(mime_q_decoder mime/q_decoder.rl ${CMAKE_CURRENT_BINARY_DIR}/mime_q_decoder.cc)
RAGEL_TARGET(mime_q_decoder_main mime/q_decoder_main.rl ${CMAKE_CURRENT_BINARY_DIR}/mime_q_decoder_main.cc)
RAGEL_TARGET(mime_header_decoder mime/header_decoder.rl ${CMAKE_CURRENT_BINARY_DIR}/mime_header_decoder.cc)
RAGEL_TARGET(ascii_control_sanitizer ascii/control_sanitizer.rl ${CMAKE_CURRENT_BINARY_DIR}/ascii_control_sanitizer.cc)
add_subdirectory(libixxx)
add_subdirectory(libbuffer)
find_package(OpenSSL REQUIRED)
option(IMAPDL_USE_BOTAN "Use botan for crypto" ON)
option(IMAPDL_USE_CRYPTOPP "Use cryptopp for crypto" OFF)
if(IMAPDL_USE_BOTAN)
find_library(LIB_CRYPTO
NAMES botan
botan-1.10 # for Fedora 20
)
find_path(HEADER_BOTAN
NAMES botan/pipe.h
# e.g. Fedora 20 stores the botan header files
# under /usr/include/botan-1.10/botan/*.h ...
PATH_SUFFIXES botan-1.10
)
include_directories(${HEADER_BOTAN})
elseif(IMAPDL_USE_CRYPTOPP)
find_library(LIB_CRYPTO NAMES cryptopp)
find_path(HEADER_CRYPTOPP NAMES cryptopp/sha.h)
include_directories(${HEADER_CRYPTOPP})
else()
message(FATAL_ERROR "Either select botan or cryptopp")
endif()
configure_file(config.h.cmake_in config.h)
add_executable(ut
imap/imap.cc
imap/client_parser_callback.cc
imap/client_writer.cc
imap/client_base.cc
maildir/maildir.cc
net/ssl_util.cc
unittest/main.cc
unittest/imap_client_parser.cc
unittest/imap_server_parser.cc
unittest/data.cc
unittest/maildir.cc
unittest/replay.cc
unittest/imap_client_writer.cc
example/server.cc
example/client.cc
${RAGEL_imap_client_parser_OUTPUTS}
${RAGEL_imap_server_parser_OUTPUTS}
lex_util.cc
unittest/sequence_set.cc
sequence_set.cc
# for imapdl
unittest/copy.cc
copy/options.cc
copy/client.cc
copy/id.cc
copy/journal.cc
copy/state.cc
copy/fetch_timer.cc
copy/header_printer.cc
net/client.cc
net/client_application.cc
net/tcp_client.cc
trace/trace.cc
log/log.cc
net/ssl_verification.cc
${RAGEL_mime_base64_decoder_main_OUTPUTS}
${RAGEL_mime_q_decoder_main_OUTPUTS}
${RAGEL_mime_header_decoder_OUTPUTS}
${RAGEL_ascii_control_sanitizer_OUTPUTS}
unittest/mime.cc
unittest/lex_util.cc
)
target_link_libraries(ut
${Boost_LIBRARIES}
${OPENSSL_SSL_LIBRARY}
${OPENSSL_CRYPTO_LIBRARY}
buffer_static ixxx_static
# for ut comparison
${LIB_CRYPTO}
)
SET_TARGET_PROPERTIES(ut
PROPERTIES LINK_FLAGS "-pthread")
add_custom_target(check COMMAND ut)
RAGEL_TARGET(length example/length.rl ${CMAKE_CURRENT_BINARY_DIR}/length.cc)
add_executable(length ${RAGEL_length_OUTPUTS})
target_link_libraries(length buffer_static ixxx_static)
add_executable(client
example/client.cc
example/client_main.cc
net/ssl_util.cc
)
target_link_libraries(client
ixxx_static
${Boost_SYSTEM_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_SERIALIZATION_LIBRARY}
${OPENSSL_SSL_LIBRARY}
${OPENSSL_CRYPTO_LIBRARY}
)
add_executable(replay
example/replay.cc
trace/trace.cc
)
target_link_libraries(replay
${Boost_SYSTEM_LIBRARY}
${Boost_SERIALIZATION_LIBRARY}
)
add_executable(server
example/server.cc
example/server_main.cc
net/ssl_util.cc
lex_util.cc
trace/trace.cc
)
target_link_libraries(server
${Boost_SYSTEM_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_SERIALIZATION_LIBRARY}
${OPENSSL_SSL_LIBRARY}
${OPENSSL_CRYPTO_LIBRARY}
)
# otherwise link error with boost log
add_definitions(-DBOOST_LOG_DYN_LINK)
add_executable(imapdl
copy/main.cc
copy/options.cc
copy/client.cc
copy/id.cc
copy/journal.cc
copy/state.cc
copy/fetch_timer.cc
copy/header_printer.cc
net/client.cc
net/client_application.cc
net/tcp_client.cc
net/ssl_util.cc
net/ssl_verification.cc
log/log.cc
imap/imap.cc
${RAGEL_imap_client_parser_OUTPUTS}
lex_util.cc
imap/client_parser_callback.cc
imap/client_writer.cc
imap/client_base.cc
${RAGEL_imap_server_parser_OUTPUTS}
maildir/maildir.cc
sequence_set.cc
trace/trace.cc
${RAGEL_mime_header_decoder_OUTPUTS}
${RAGEL_ascii_control_sanitizer_OUTPUTS}
)
target_link_libraries(imapdl
ixxx_static
buffer_static
${Boost_SYSTEM_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_SERIALIZATION_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_LOG_LIBRARY}
${Boost_LOG_SETUP_LIBRARY}
${Boost_THREAD_LIBRARY}
${Boost_LOCALE_LIBRARY}
${Boost_REGEX_LIBRARY}
${OPENSSL_SSL_LIBRARY}
${OPENSSL_CRYPTO_LIBRARY}
)
SET_TARGET_PROPERTIES(imapdl
PROPERTIES LINK_FLAGS "-pthread")
add_executable(hash
example/hash.cc
)
target_link_libraries(hash
${LIB_CRYPTO}
)