-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCMakeLists.txt
66 lines (57 loc) · 1.74 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
cmake_minimum_required(VERSION 3.9)
project(
multithread-libevent-example
VERSION 0.0.1
LANGUAGES C CXX)
# It's 21 century!
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(ImportLibrary)
# valgrind need
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-builtin-strlen")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-strlen")
# sanitize
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -fsanitize-address-use-after-scope"
)
# download libevent
set(EVENT__LIBRARY_TYPE "STATIC")
import_library(
libevent
https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
b5333f021f880fe76490d8a799cd79f4)
add_subdirectory(${IMPORT_SRC} ${IMPORT_BUILD} EXCLUDE_FROM_ALL)
# download google test
import_library(
googletest
https://github.com/google/googletest/archive/refs/tags/release-1.10.0.zip
82358affdd7ab94854c8ee73a180fc53)
add_subdirectory(${IMPORT_SRC} ${IMPORT_BUILD} EXCLUDE_FROM_ALL)
import_library(
spdlog https://github.com/gabime/spdlog/archive/refs/tags/v1.8.5.zip
06cd154999c8019f52e57afe4a8068f0)
add_subdirectory(${IMPORT_SRC} ${IMPORT_BUILD} EXCLUDE_FROM_ALL)
# add target
set(EXEC_NAME multithread-libevent-example)
add_executable(
${EXEC_NAME}
main.cc
buffer.cc
buffer.h
thread_pool.h
thread_pool.cc
dispatcher.h
dispatcher.cc
handler.cc
handler.h
listener.cc
listener.h)
# dependency libraries
target_link_libraries(${EXEC_NAME} event_core event_pthreads event_extra
spdlog::spdlog)
# Be regorous
target_compile_options(${EXEC_NAME} PUBLIC -Werror -Wall -Wextra -pedantic)
# test
add_subdirectory(tests)