-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
129 lines (107 loc) · 2.89 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
cmake_minimum_required(VERSION 3.7)
project(WebDc)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(Threads REQUIRED)
find_package(OpenSSL REQUIRED)
if(OPENSSL_FOUND)
message(STATUS "OpenSSL found: ${OPENSSL_INCLUDE_DIR}, ${OPENSSL_CRYPTO_LIBRARY}, ${OPENSSL_SSL_LIBRARY}")
message(STATUS "OpenSSL version: ${OPENSSL_VERSION}")
else()
message(FATAL_ERROR "OpenSSL not found")
endif()
if (${OPENSSL_VERSION} VERSION_LESS "1.0.2")
message(FATAL_ERROR "Invalid OpenSSL version ${OPENSSL_VERSION}")
endif()
option(WITH_TESTS "Build tests" ON)
set(EXAMPLES_DIR ${CMAKE_CURRENT_BINARY_DIR}/examples)
add_library(Dc
src/CRC32.cc
src/Dc.cc
src/BarePool.cc
src/Pool.cc
src/Sctp.cc
src/Sdp.cc
src/String.cc
src/Stun.cc
src/Crypto.cc
src/Rng.cc
src/Queue.cc
)
if (UNIX AND NOT APPLE)
add_library(Host
src/HostEpoll.cc
src/Network.cc
src/picohttpparser.c
)
else ()
message(WARNING "Unsupported platform, defaulting to null (no-op) implementation")
add_library(Host
HostNull.cc
)
endif()
target_include_directories(Dc
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
PRIVATE OpenSSL::SSL
)
target_include_directories(Host
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(Dc
PRIVATE OpenSSL::SSL
PRIVATE OpenSSL::Crypto
PRIVATE Threads::Threads
)
target_link_libraries(Host Dc)
target_compile_options(Dc
PRIVATE
-Wall
-fPIC
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
)
target_compile_options(Host
PRIVATE
-Wall
$<$<COMPILE_LANGUAGE:CXX>:-fno-exceptions>
$<$<COMPILE_LANGUAGE:CXX>:-fno-rtti>
)
install(TARGETS Dc Host EXPORT Targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
PUBLIC_HEADER DESTINATION include
)
install(FILES src/Dc.h src/Host.h DESTINATION include)
install(EXPORT Targets
FILE Targets.cmake
NAMESPACE Dc::
DESTINATION lib/cmake/Dc
)
add_executable(EchoServer examples/EchoServer.c)
target_include_directories(EchoServer PUBLIC src/)
target_link_libraries(EchoServer Host)
set_target_properties(Dc Host EchoServer PROPERTIES
CXX_STANDARD 11
RUNTIME_OUTPUT_DIRECTORY ${EXAMPLES_DIR}
)
file(MAKE_DIRECTORY ${EXAMPLES_DIR})
file(COPY examples/client DESTINATION ${EXAMPLES_DIR})
if (WITH_TESTS)
set(TESTS_DIR ${CMAKE_CURRENT_BINARY_DIR}/test)
file(MAKE_DIRECTORY ${TESTS_DIR})
add_executable(FuzzSdp test/FuzzSdp.cc)
add_executable(FuzzSctp test/FuzzSctp.cc)
add_executable(FuzzStun test/FuzzStun.cc)
target_include_directories(FuzzSdp PUBLIC src/)
target_include_directories(FuzzSctp PUBLIC src/)
target_include_directories(FuzzStun PUBLIC src/)
target_link_libraries(FuzzSdp Dc)
target_link_libraries(FuzzSctp Dc)
target_link_libraries(FuzzStun Dc)
file(COPY test/data DESTINATION ${TESTS_DIR})
endif()