forked from MisterTea/EternalTerminal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
283 lines (240 loc) · 5.45 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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
cmake_minimum_required (VERSION 3.0.2)
project (EternalTCP VERSION 5.1.9)
option(BUILD_TEST "Build all unit test" OFF)
option(CODE_COVERAGE "Enable code coverage" OFF)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DET_VERSION='\"${PROJECT_VERSION}\"'")
# For easylogging, disable default log file, enable crash log, ensure thread safe, and catch c++ exceptions
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DELPP_NO_DEFAULT_LOG_FILE -DELPP_FEATURE_CRASH_LOG -DELPP_THREAD_SAFE -DELPP_HANDLE_SIGABRT")
IF(BUILD_TEST)
add_subdirectory(${CMAKE_SOURCE_DIR}/external/googletest)
ENDIF(BUILD_TEST)
IF(CODE_COVERAGE)
if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
endif()
ENDIF(CODE_COVERAGE)
# Enable C++-11
if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11")
endif()
# Enable debug info
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
#Using FreeBSD?
if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
set(FREEBSD TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
#Using NetBSD?
if (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
set(NETBSD TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "NetBSD")
# Add cmake script directory.
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Required packages
find_package(Threads REQUIRED)
find_package(GFlags REQUIRED)
find_package(Protobuf REQUIRED)
find_package(Sodium REQUIRED)
# Optional packages
IF(LINUX)
find_package(SELinux)
ENDIF()
find_package(UTempter)
IF(SELINUX_FOUND)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITH_SELINUX")
ELSE()
SET(SELINUX_INCLUDE_DIR "")
SET(SELINUX_LIBRARIES "")
ENDIF()
IF(UTEMPTER_FOUND)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DWITH_UTEMPTER")
ELSE()
SET(UTEMPTER_INCLUDE_DIR "")
SET(UTEMPTER_LIBRARIES "")
ENDIF()
PROTOBUF_GENERATE_CPP(
ET_SRCS
ET_HDRS
proto/ET.proto
)
PROTOBUF_GENERATE_CPP(
ETERMINAL_SRCS
ETERMINAL_HDRS
proto/ETerminal.proto
)
add_custom_target(
generated-code
DEPENDS
${ET_SRCS} ${ET_HDRS}
${ETERMINAL_SRCS} ${ETERMINAL_HDRS}
)
IF(FREEBSD)
set(CORE_LIBRARIES util execinfo)
ELSEIF(NETBSD)
set(CORE_LIBRARIES util resolv execinfo)
ELSE()
set(CORE_LIBRARIES util resolv)
ENDIF()
include_directories(
external
src/base
src/terminal
src/htm
${PROTOBUF_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}
${CURSES_INCLUDE_DIR}
${sodium_INCLUDE_DIR}
${GFLAGS_INCLUDE_DIRS}
${SELINUX_INCLUDE_DIR}
${UTEMPTER_INCLUDE_DIR}
)
add_library(
et-lib
STATIC
external/easylogging++.cc
src/base/BackedReader.cpp
src/base/BackedWriter.cpp
src/base/ClientConnection.cpp
src/base/Connection.cpp
src/base/CryptoHandler.cpp
src/base/ServerClientConnection.cpp
src/base/ServerConnection.cpp
src/base/SocketHandler.cpp
src/base/PipeSocketHandler.cpp
src/base/TcpSocketHandler.cpp
src/base/UnixSocketHandler.cpp
src/base/LogHandler.cpp
src/base/DaemonCreator.cpp
src/base/SystemUtils.cpp
src/base/RawSocketUtils.cpp
${ET_SRCS}
)
add_dependencies(
et-lib
generated-code
)
add_library(
TerminalCommon
STATIC
src/terminal/PortForwardHandler.cpp
src/terminal/PortForwardSourceHandler.cpp
src/terminal/PortForwardDestinationHandler.cpp
${ETERMINAL_SRCS} ${ETERMINAL_HDRS}
)
add_dependencies(
TerminalCommon
generated-code
)
add_executable (
etserver
src/terminal/TerminalServer.cpp
src/terminal/UserTerminalRouter.cpp
)
target_link_libraries (
etserver
LINK_PUBLIC
TerminalCommon
et-lib
${CMAKE_THREAD_LIBS_INIT}
${PROTOBUF_LIBRARIES}
${GFLAGS_LIBRARIES}
${sodium_LIBRARY_RELEASE}
${SELINUX_LIBRARIES}
${UTEMPTER_LIBRARIES}
${CORE_LIBRARIES}
)
add_executable (
etterminal
src/terminal/Terminal.cpp
src/terminal/UserTerminalHandler.cpp
)
target_link_libraries (
etterminal
LINK_PUBLIC
TerminalCommon
et-lib
${CMAKE_THREAD_LIBS_INIT}
${PROTOBUF_LIBRARIES}
${GFLAGS_LIBRARIES}
${sodium_LIBRARY_RELEASE}
${SELINUX_LIBRARIES}
${UTEMPTER_LIBRARIES}
${CORE_LIBRARIES}
)
add_executable (
et
src/terminal/TerminalClient.cpp
src/terminal/SshSetupHandler.cpp
)
target_link_libraries (
et
LINK_PUBLIC
TerminalCommon
et-lib
${CMAKE_THREAD_LIBS_INIT}
${PROTOBUF_LIBRARIES}
${GFLAGS_LIBRARIES}
${sodium_LIBRARY_RELEASE}
${UTEMPTER_LIBRARIES}
${CORE_LIBRARIES}
)
add_library (
HtmCommon
STATIC
src/htm/TerminalHandler.cpp
src/htm/MultiplexerState.cpp
src/htm/IpcPairClient.cpp
src/htm/IpcPairEndpoint.cpp
src/htm/IpcPairServer.cpp
src/htm/HtmClient.cpp
src/htm/HtmServer.cpp
)
add_dependencies(
HtmCommon
generated-code
)
add_executable (
htm
src/htm/HtmClientMain.cpp
)
target_link_libraries (
htm
LINK_PUBLIC
HtmCommon
et-lib
${CMAKE_THREAD_LIBS_INIT}
${PROTOBUF_LIBRARIES}
${GLOG_LIBRARIES}
${GFLAGS_LIBRARIES}
${sodium_LIBRARY_RELEASE}
${SELINUX_LIBRARIES}
${UTEMPTER_LIBRARIES}
${CORE_LIBRARIES}
)
add_executable (
htmd
src/htm/HtmServerMain.cpp
)
target_link_libraries (
htmd
LINK_PUBLIC
HtmCommon
et-lib
${CMAKE_THREAD_LIBS_INIT}
${PROTOBUF_LIBRARIES}
${GLOG_LIBRARIES}
${GFLAGS_LIBRARIES}
${sodium_LIBRARY_RELEASE}
${SELINUX_LIBRARIES}
${UTEMPTER_LIBRARIES}
${CORE_LIBRARIES}
)
if(BUILD_TEST) # Build unit tests.
message(STATUS "Enabling test for ${PROJECT_NAME}")
enable_testing()
add_subdirectory(test)
endif()
install(TARGETS etserver etterminal et htm htmd
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ
DESTINATION "bin"
)