-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
455 lines (414 loc) · 17.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
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
cmake_minimum_required(VERSION 3.16)
project(dhtnet
VERSION 0.0.1
LANGUAGES CXX
DESCRIPTION "A C++ library for NAT traversal and secure communication")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(CTest)
include(GNUInstallDirs)
include(CheckIncludeFileCXX)
set (prefix ${CMAKE_INSTALL_PREFIX})
set (exec_prefix "\${prefix}")
set (libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
set (includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
set (bindir "${CMAKE_INSTALL_FULL_BINDIR}")
set (sysconfdir "${CMAKE_INSTALL_FULL_SYSCONFDIR}")
set (docdir "${CMAKE_INSTALL_FULL_DOCDIR}")
set (top_srcdir "${CMAKE_CURRENT_SOURCE_DIR}")
set (VERSION ${CMAKE_PROJECT_VERSION})
option(DHTNET_PUPNP "Enable UPnP support" ON)
option(DHTNET_NATPMP "Enable NAT-PMP support" ON)
option(BUILD_DEPS_STATIC "Enable to force building dependencies as static" OFF)
option(TRIM_PREFIX_PATH "Used for some RPM build, trim INSTALL_PREFIX from absolute path" OFF)
option(BUILD_TOOLS "Build tools" ON)
option(BUILD_BENCHMARKS "Build benchmarks" ON)
option(BUILD_DEPENDENCIES "Build dependencies" ON)
option(DNC_SYSTEMD_UNIT_FILE_LOCATION "Where to install systemd unit file")
option(DNC_SYSTEMD "Enable dnc systemd integration" ON)
option(CODE_COVERAGE "Enable coverage reporting" OFF)
option(BUILD_EXAMPLE "Build example" ON)
# Check if testing is enabled
if(BUILD_TESTING)
if(CODE_COVERAGE)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
# Add the flags for coverage
add_compile_options(-fprofile-arcs -ftest-coverage --coverage -O0)
link_libraries(--coverage)
endif()
endif()
endif()
if (NOT MSVC)
# Check if there's a recent enough version of msgpack installed on the system
find_package(msgpack 5.0.0 QUIET CONFIG NAMES msgpack msgpackc-cxx)
if (msgpack_FOUND)
set(MSGPACK_TARGET "msgpackc-cxx")
else()
find_package(msgpack 5.0.0 QUIET CONFIG NAMES msgpack-cxx)
if (msgpack_FOUND)
set(MSGPACK_TARGET "msgpack-cxx")
endif()
endif()
# If no suitable version of msgpack was found, build the one
# included as a submodule in the dependencies folder
if (NOT msgpack_FOUND)
set(DEPENDENCIES_BUILD_ARGS "--build-msgpack")
else()
set(DEPENDENCIES_BUILD_ARGS "")
endif()
set(DEPENDENCIES_PATH ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/install/${TARGET})
message("dependencies path: ${DEPENDENCIES_PATH}")
if (BUILD_DEPENDENCIES)
find_package(Python3 COMPONENTS Interpreter)
execute_process(
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/build.py ${DEPENDENCIES_BUILD_ARGS}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dependencies
RESULT_VARIABLE BUILD_RESULT
)
if (BUILD_RESULT)
message(FATAL_ERROR "Failed to execute build.py script.")
endif()
endif()
include (GNUInstallDirs)
list(APPEND CMAKE_FIND_ROOT_PATH ${DEPENDENCIES_PATH})
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH)
list(APPEND CMAKE_PREFIX_PATH ${DEPENDENCIES_PATH})
find_package (PkgConfig REQUIRED)
if(BUILD_DEPS_STATIC OR NOT BUILD_SHARED_LIBS)
list(APPEND PKG_CONFIG_EXECUTABLE "--static")
endif()
if (BUILD_TOOLS)
find_package(yaml-cpp REQUIRED)
endif()
include_directories(${YAML_CPP_INCLUDE_DIR})
find_package(fmt)
pkg_search_module (opendht REQUIRED IMPORTED_TARGET opendht)
pkg_search_module (pjproject REQUIRED IMPORTED_TARGET libpjproject)
else()
set (WIN32_DEP_DIR ${PROJECT_SOURCE_DIR}/../)
include_directories(
${WIN32_DEP_DIR}/../msvc/include
${WIN32_DEP_DIR}/msgpack-c/include
${WIN32_DEP_DIR}/asio/asio/include
${WIN32_DEP_DIR}/fmt/include
${WIN32_DEP_DIR}/pjproject/pjlib/include
${WIN32_DEP_DIR}/pjproject/pjlib-util/include
${WIN32_DEP_DIR}/pjproject/pjnath/include
${WIN32_DEP_DIR}/opendht/include
${WIN32_DEP_DIR}/opendht/src/compat/msvc
${WIN32_DEP_DIR}/openssl/include
${WIN32_DEP_DIR}/restinio/dev
${WIN32_DEP_DIR}/llhttp/include
${WIN32_DEP_DIR}/pupnp/include
${WIN32_DEP_DIR}/natpmp/include
)
# windirent.h
include_directories(include/compat/msvc)
endif()
if (NOT MSVC)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-DMSGPACK_NO_BOOST \
-DMSGPACK_DISABLE_LEGACY_NIL \
-DMSGPACK_DISABLE_LEGACY_CONVERT")
else()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
-DGNUTLS_INTERNAL_BUILD \
-D_USE_MATH_DEFINES \
-D_SCL_SECURE_NO_WARNINGS \
-D_CRT_SECURE_NO_WARNINGS \
-D_WINSOCK_DEPRECATED_NO_WARNINGS \
-DASIO_STANDALONE \
-DWIN32_LEAN_AND_MEAN \
-D_WIN32_WINNT=0x0601 \
-DNATPMP_STATICLIB \
-DMSGPACK_NO_BOOST \
-DMSGPACK_DISABLE_LEGACY_NIL \
-DMSGPACK_DISABLE_LEGACY_CONVERT \
-DUNICODE \
-D_UNICODE \
-DNOMINMAX \
")
endif()
if (DNC_SYSTEMD AND BUILD_TOOLS AND NOT MSVC)
if (NOT DEFINED DNC_SYSTEMD_UNIT_FILE_LOCATION OR NOT DNC_SYSTEMD_UNIT_FILE_LOCATION)
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} systemd --variable=systemdsystemunitdir
OUTPUT_VARIABLE SYSTEMD_UNIT_INSTALL_DIR)
message("-- Using Systemd unit installation directory by pkg-config: " ${SYSTEMD_UNIT_INSTALL_DIR})
else()
message("-- Using Systemd unit installation directory requested: " ${DNC_SYSTEMD_UNIT_FILE_LOCATION})
set(SYSTEMD_UNIT_INSTALL_DIR ${DNC_SYSTEMD_UNIT_FILE_LOCATION})
endif()
if (NOT DEFINED DNC_SYSTEMD_PRESET_FILE_LOCATION OR NOT DNC_SYSTEMD_PRESET_FILE_LOCATION)
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE} systemd --variable=systemdsystempresetdir
OUTPUT_VARIABLE SYSTEMD_PRESET_INSTALL_DIR)
message("-- Using Systemd preset installation directory by pkg-config: " ${SYSTEMD_PRESET_INSTALL_DIR})
else()
message("-- Using Systemd preset installation directory requested: " ${DNC_SYSTEMD_PRESET_FILE_LOCATION})
set(SYSTEMD_PRESET_INSTALL_DIR ${DNC_SYSTEMD_PRESET_FILE_LOCATION})
endif()
configure_file (
tools/dnc/systemd/dnc.service.in
systemd/dnc.service
@ONLY
)
if (TRIM_PREFIX_PATH)
file(READ ${CMAKE_CURRENT_BINARY_DIR}/systemd/dnc.service FILE_CONTENTS)
string(REPLACE "${CMAKE_INSTALL_PREFIX}" "" FILE_CONTENTS "${FILE_CONTENTS}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/systemd/dnc.service "${FILE_CONTENTS}")
endif()
if (SYSTEMD_UNIT_INSTALL_DIR)
string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_UNIT_INSTALL_DIR "${SYSTEMD_UNIT_INSTALL_DIR}")
set (systemdunitdir "${SYSTEMD_UNIT_INSTALL_DIR}")
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/systemd/dnc.service DESTINATION ${systemdunitdir})
string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_PRESET_INSTALL_DIR "${SYSTEMD_PRESET_INSTALL_DIR}")
set (systemdpresetdir "${SYSTEMD_PRESET_INSTALL_DIR}")
install (FILES tools/dnc/systemd/dhtnet-dnc.preset DESTINATION ${systemdpresetdir})
install (FILES tools/dnc/dnc.yaml DESTINATION ${sysconfdir}/dhtnet/)
else()
message(WARNING "Systemd unit installation directory not found. The systemd unit is unable to be installed.")
endif()
endif()
# Sources
list (APPEND dhtnet_SOURCES
src/connectionmanager.cpp
src/ice_transport.cpp
src/multiplexed_socket.cpp
src/peer_connection.cpp
src/string_utils.cpp
src/fileutils.cpp
src/ip_utils.cpp
src/security/tls_session.cpp
src/security/certstore.cpp
src/security/threadloop.cpp
src/security/diffie-hellman.cpp
src/turn/turn_cache.cpp
src/turn/turn_transport.cpp
src/upnp/upnp_context.cpp
src/upnp/upnp_control.cpp
src/upnp/protocol/mapping.cpp
src/upnp/protocol/igd.cpp
)
list (APPEND dhtnet_HEADERS
include/connectionmanager.h
include/multiplexed_socket.h
include/tls_session.h
include/certstore.h
include/ice_options.h
include/ice_transport.h
include/ice_transport_factory.h
include/ice_socket.h
include/fileutils.h
include/string_utils.h
include/ip_utils.h
include/upnp/mapping.h
include/upnp/upnp_context.h
include/upnp/upnp_control.h
)
# Port mapping dependencies - add sources and libraries
if (DHTNET_PUPNP AND NOT MSVC)
pkg_search_module (upnp IMPORTED_TARGET upnp libupnp)
if (NOT upnp_FOUND)
message("libupnp not found: disabling")
set(DHTNET_PUPNP Off)
else()
message("libupnp found")
set(upnp_LIBRARIES PkgConfig::upnp)
set (requiresprivate "${requiresprivate} libupnp")
endif()
endif()
if (DHTNET_NATPMP AND NOT MSVC)
pkg_search_module (natpmp IMPORTED_TARGET natpmp)
if (NOT natpmp_FOUND)
find_library(natpmp_LIBRARIES natpmp)
if (NOT natpmp_LIBRARIES)
message("NAT-PMP not found: disabling")
set(DHTNET_NATPMP Off)
else()
message("NAT-PMP found: ${natpmp_LIBRARIES}")
set (libsprivate "${libsprivate} -lnatpmp")
endif()
else()
message("NAT-PMP found")
set(natpmp_LIBRARIES PkgConfig::natpmp)
set (requiresprivate "${requiresprivate} natpmp")
endif()
endif()
if (DHTNET_PUPNP)
list (APPEND dhtnet_PRIVATE_DEFS HAVE_LIBUPNP)
list (APPEND dhtnet_SOURCES
src/upnp/protocol/pupnp/pupnp.cpp
src/upnp/protocol/pupnp/upnp_igd.cpp
)
list (APPEND dhtnet_PRIVATELIBS ${upnp_LIBRARIES})
endif()
if (DHTNET_NATPMP)
list (APPEND dhtnet_PRIVATE_DEFS HAVE_LIBNATPMP)
list (APPEND dhtnet_SOURCES
src/upnp/protocol/natpmp/nat_pmp.cpp
src/upnp/protocol/natpmp/pmp_igd.cpp
)
list (APPEND dhtnet_PRIVATELIBS ${natpmp_LIBRARIES})
endif()
add_library(dhtnet ${dhtnet_SOURCES})
if (NOT MSVC)
target_link_libraries(dhtnet PUBLIC PkgConfig::opendht PkgConfig::pjproject fmt::fmt ${MSGPACK_LIB})
else()
target_link_libraries(dhtnet PUBLIC
${WIN32_DEP_DIR}/../msvc/lib/libopendht.lib
${WIN32_DEP_DIR}/../msvc/lib/libpjproject.lib
${WIN32_DEP_DIR}/../msvc/lib/libfmt.lib
${WIN32_DEP_DIR}/../msvc/lib/libmsgpackc-cxx.lib)
endif()
if (msgpack_FOUND)
target_link_libraries(dhtnet PUBLIC ${MSGPACK_TARGET})
endif()
if (APPLE)
target_link_libraries(dhtnet PRIVATE "-framework CoreFoundation" "-framework Security" "resolv")
endif()
target_include_directories(dhtnet PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_compile_definitions(dhtnet PRIVATE ${dhtnet_PRIVATE_DEFS})
target_link_libraries(dhtnet PRIVATE ${dhtnet_PRIVATELIBS})
if (MSVC)
target_compile_definitions(dhtnet PRIVATE
_CRT_SECURE_NO_WARNINGS
_WINSOCK_DEPRECATED_NO_WARNINGS
ASIO_STANDALONE
_WIN32_WINNT=0x0601
MSGPACK_NO_BOOST
MSGPACK_DISABLE_LEGACY_NIL
MSGPACK_DISABLE_LEGACY_CONVERT
DHTNET_STATIC
DHTNET_STATIC_DEFINE
DHTNET_EXPORTS
DHTNET_BUILDING
DHT)
target_compile_options(dhtnet PRIVATE
/O2; /Oi; ${DEFAULT_CXX_RUNTIME_LIBRARY}; /Gy; /MP; /Oy-; /sdl-; /W0;
/FC; /FS; /nologo; /Zi; /wd4996; /wd4503; /wd4180; /wd4244; /wd4267;
/Zc:__cplusplus;
${DEFAULT_CXX_EXCEPTION_HANDLING})
else()
target_compile_definitions(dhtnet PUBLIC PJ_AUTOCONF=1)
endif()
if (BUILD_TESTING AND NOT MSVC)
target_compile_definitions(dhtnet PUBLIC DHTNET_TESTABLE)
endif()
configure_file(dhtnet.pc.in dhtnet.pc @ONLY)
if (TRIM_PREFIX_PATH)
file(READ ${CMAKE_CURRENT_BINARY_DIR}/dhtnet.pc FILE_CONTENTS)
string(REPLACE "${CMAKE_INSTALL_PREFIX}" "" FILE_CONTENTS "${FILE_CONTENTS}")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/dhtnet.pc "${FILE_CONTENTS}")
endif()
# Install targets
install(TARGETS dhtnet)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dhtnet)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dhtnet.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
if (BUILD_TOOLS AND NOT MSVC)
add_executable(dnc
tools/dnc/main.cpp
tools/dnc/dnc.cpp
tools/common.cpp
tools/dhtnet_crtmgr/dhtnet_crtmgr.cpp)
target_link_libraries(dnc PRIVATE dhtnet fmt::fmt yaml-cpp)
target_include_directories(dnc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools)
install(TARGETS dnc RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
add_executable(dsh
tools/dsh/main.cpp
tools/dsh/dsh.cpp
tools/common.cpp
tools/dhtnet_crtmgr/dhtnet_crtmgr.cpp)
target_link_libraries(dsh PRIVATE dhtnet fmt::fmt yaml-cpp)
target_include_directories(dsh PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools)
install(TARGETS dsh RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
# dvpn is a Linux-only tool
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
add_executable(dvpn
tools/dvpn/main.cpp
tools/dvpn/dvpn.cpp
tools/common.cpp
tools/dhtnet_crtmgr/dhtnet_crtmgr.cpp)
target_link_libraries(dvpn PRIVATE dhtnet fmt::fmt yaml-cpp)
target_include_directories(dvpn PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools)
install(TARGETS dvpn RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
find_library(READLINE_LIBRARIES readline)
find_path(READLINE_INCLUDE_DIR readline/readline.h)
add_library(readline STATIC IMPORTED)
set_target_properties(readline PROPERTIES
IMPORTED_LOCATION "${READLINE_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${READLINE_INCLUDE_DIR}")
add_executable(upnpctrl
tools/upnp/upnpctrl.cpp)
target_link_libraries(upnpctrl PRIVATE dhtnet fmt::fmt readline)
target_include_directories(upnpctrl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools)
install(TARGETS upnpctrl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
add_executable(dhtnet-crtmgr
tools/dhtnet_crtmgr/main.cpp
tools/dhtnet_crtmgr/dhtnet_crtmgr.cpp)
target_link_libraries(dhtnet-crtmgr PRIVATE dhtnet fmt::fmt)
target_include_directories(dhtnet-crtmgr PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools)
install(TARGETS dhtnet-crtmgr RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
add_executable(peerDiscovery
tools/peerdiscovery/peerDiscovery.cpp)
target_link_libraries(peerDiscovery PRIVATE dhtnet fmt::fmt readline)
target_include_directories(peerDiscovery PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools/peerdiscovery)
install(TARGETS peerDiscovery RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES
tools/dnc/dnc.1
tools/dsh/dsh.1
tools/dvpn/dvpn.1
tools/dhtnet_crtmgr/dhtnet-crtmgr.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
install(FILES README.md DESTINATION ${docdir})
install(FILES tools/dnc/README.md RENAME DNC.md DESTINATION ${docdir})
install(FILES tools/dsh/README.md RENAME DSH.md DESTINATION ${docdir})
install(FILES tools/dvpn/README.md RENAME DVPN.md DESTINATION ${docdir})
install(FILES tools/dhtnet_crtmgr/README.md RENAME DHTNET_CRTMGR.md DESTINATION ${docdir})
endif()
if (BUILD_BENCHMARKS)
add_executable(bench
tools/benchmark/main.cpp
tools/common.cpp)
target_link_libraries(bench PRIVATE dhtnet fmt::fmt)
target_include_directories(bench PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools)
install(TARGETS bench RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if (BUILD_TESTING AND NOT MSVC)
pkg_search_module(Cppunit REQUIRED IMPORTED_TARGET cppunit)
add_executable(tests_certstore tests/certstore.cpp)
target_link_libraries(tests_certstore PRIVATE dhtnet fmt::fmt PkgConfig::Cppunit)
add_test(NAME tests_certstore COMMAND tests_certstore)
add_executable(tests_connectionManager tests/connectionManager.cpp)
target_link_libraries(tests_connectionManager PRIVATE dhtnet fmt::fmt PkgConfig::Cppunit)
add_test(NAME tests_connectionManager COMMAND tests_connectionManager)
add_executable(tests_fileutils tests/testFileutils.cpp)
target_link_libraries(tests_fileutils PRIVATE dhtnet fmt::fmt PkgConfig::Cppunit)
add_test(NAME tests_fileutils COMMAND tests_fileutils)
add_executable(tests_ice tests/ice.cpp)
target_link_libraries(tests_ice PRIVATE dhtnet fmt::fmt PkgConfig::Cppunit)
add_test(NAME tests_ice COMMAND tests_ice)
add_executable(tests_turnCache tests/turnCache.cpp)
target_link_libraries(tests_turnCache PRIVATE dhtnet fmt::fmt PkgConfig::Cppunit)
add_test(NAME tests_turnCache COMMAND tests_turnCache)
add_executable(tests_peerDiscovery tests/peerDiscovery.cpp)
target_link_libraries(tests_peerDiscovery PRIVATE dhtnet fmt::fmt PkgConfig::Cppunit)
add_test(NAME tests_peerDiscovery COMMAND tests_peerDiscovery)
#add_executable(tests_stringutils tests/testString_utils.cpp)
#target_link_libraries(tests_stringutils PRIVATE dhtnet fmt::fmt PkgConfig::Cppunit)
#add_test(NAME tests_stringutils COMMAND tests_stringutils)
endif()
if (BUILD_EXAMPLES AND NOT MSVC)
add_executable(server
example/server.cpp)
target_link_libraries(server PRIVATE dhtnet)
target_include_directories(server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/example)
install(TARGETS server RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
add_executable(client
example/client.cpp)
target_link_libraries(client PRIVATE dhtnet)
target_include_directories(client PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/example)
install(TARGETS client RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()