-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
161 lines (128 loc) · 3.22 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
cmake_minimum_required(VERSION 3.5)
project(MrUDP)
add_definitions(-DMRUDP_NO_CORE)
if(USE_CRYPTO)
find_package(OpenSSL REQUIRED)
target_link_libraries(untitled OpenSSL::SSL)
else()
endif()
# this is for github actions
if (BOOST_ROOT)
link_directories(${BOOST_ROOT}/lib)
endif()
find_package(Boost)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
# this doesn_t seem to work at all, although this *should* work
link_directories(${Boost_LIBRARY_DIRS})
# this only seems to work on win32 with boost installed from .exe
link_directories(${Boost_INCLUDE_DIRS}/lib)
else()
message( FATAL_ERROR "please specify BOOST_ROOT=/place/where/boost/is/boost <-- not a relative path!")
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
if (WIN32)
add_definitions(-DSYS_WINDOWS)
endif ()
if (APPLE)
add_definitions(-DSYS_APPLE)
endif ()
if(UNIX AND NOT APPLE)
add_definitions(-DSYS_LINUX)
endif ()
if (WIN32)
set(CMAKE_CXX_STANDARD 20)
else ()
set(CMAKE_CXX_STANDARD 17)
endif ()
if (WIN32)
link_libraries(wsock32 ws2_32)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED True)
############################################################
# Create a library
############################################################
#Generate the static library from the library sources
add_library(MrUDP STATIC
mrudp/mrudp.cpp
mrudp/mrudp_proxy.hpp
mrudp/Base.cpp
mrudp/Connection.cpp
mrudp/Handshake.cpp
mrudp/NetworkPath.cpp
mrudp/Packet.cpp
mrudp/Proxy.cpp
mrudp/Scheduler.cpp
mrudp/Service.cpp
mrudp/Socket.cpp
mrudp/Statistics.cpp
mrudp/Types.cpp
mrudp/Handshake_Options.cpp
mrudp/connection/Probe.cpp
mrudp/imp/Asio.cpp
mrudp/receiver/ReceiveQueue.cpp
mrudp/receiver/Receiver.cpp
mrudp/sender/Retrier.cpp
mrudp/sender/Sender.cpp
mrudp/sender/SendQueue.cpp
mrudp/receiver/UnreliableReceiveQueue.cpp
)
if(USE_CRYPTO)
target_sources(MrUDP PRIVATE
mrudp/Crypto.cpp
mrudp/imp/CryptoOpenSSL.cpp
)
else()
endif()
target_include_directories(MrUDP
PUBLIC
${PROJECT_SOURCE_DIR}
)
############################################################
# Create an executable
############################################################
# Add an executable with the above sources
add_executable(MrUDP-Tests
tests/Basics.cpp
tests/Connections.cpp
tests/ConnectionTimesOutAtBeginning.cpp
tests/MaximumTransferRate.cpp
tests/NetworkPathChange.cpp
tests/PacketID.cpp
tests/StandaloneCore.cpp
tests/Streams.cpp
tests/Run.cpp
)
if(USE_CRYPTO)
target_sources(MrUDP-Tests PRIVATE
tests/Crypto.cpp
)
else()
endif()
# Add an executable with the above sources
add_executable(MrUDP-Examples
examples/Run.cpp
examples/EchoClient.cpp
examples/EchoClient.c
examples/EchoServer.cpp
examples/EchoServer.c
)
if(USE_CRYPTO)
target_sources(MrUDP-Examples PRIVATE
tests/Crypto.cpp
)
else()
endif()
# link the new hello_library target with the hello_binary target
target_link_libraries( MrUDP-Tests
PRIVATE
MrUDP
Threads::Threads
)
# link the new hello_library target with the hello_binary target
target_link_libraries( MrUDP-Examples
PRIVATE
MrUDP
Threads::Threads
)