Adrien Béraud | 53bc445 | 2023-07-12 11:15:13 -0400 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.16) |
Adrien Béraud | d50178b | 2023-07-09 21:41:12 -0400 | [diff] [blame] | 2 | project(dhtnet |
| 3 | VERSION 0.0.1 |
| 4 | LANGUAGES CXX |
| 5 | DESCRIPTION "A C++ library for NAT traversal and secure communication") |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 6 | |
| 7 | set(CMAKE_CXX_STANDARD 17) |
| 8 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
Adrien Béraud | efe2737 | 2023-05-27 18:56:29 -0400 | [diff] [blame] | 9 | include(CTest) |
Adrien Béraud | 665d111 | 2023-06-01 19:03:57 -0400 | [diff] [blame] | 10 | include(GNUInstallDirs) |
Amna | 366382f | 2023-10-02 16:37:02 -0400 | [diff] [blame] | 11 | include(CheckIncludeFileCXX) |
Adrien Béraud | a4030cd | 2023-06-21 09:35:40 -0400 | [diff] [blame] | 12 | set (prefix ${CMAKE_INSTALL_PREFIX}) |
| 13 | set (exec_prefix "\${prefix}") |
| 14 | set (libdir "${CMAKE_INSTALL_FULL_LIBDIR}") |
| 15 | set (includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}") |
Adrien Béraud | d50178b | 2023-07-09 21:41:12 -0400 | [diff] [blame] | 16 | set (VERSION ${CMAKE_PROJECT_VERSION}) |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 17 | |
Adrien Béraud | 370257c | 2023-08-15 20:53:09 -0400 | [diff] [blame] | 18 | option(DHTNET_PUPNP "Enable UPnP support" ON) |
| 19 | option(DHTNET_NATPMP "Enable NAT-PMP support" ON) |
Adrien Beraud | b975dbf | 2023-08-22 17:33:42 -0400 | [diff] [blame] | 20 | option(DHTNET_TESTABLE "Enable API for tests" ON) |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 21 | option(BUILD_TOOLS "Build tools" ON) |
Adrien Béraud | 6c6a962 | 2023-08-27 12:49:31 -0400 | [diff] [blame] | 22 | option(BUILD_BENCHMARKS "Build benchamrks" ON) |
Amna | 41d7662 | 2023-09-20 11:14:27 -0400 | [diff] [blame] | 23 | option(BUILD_DEPENDENCIES "Build dependencies" ON) |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 24 | |
| 25 | if (NOT MSVC) |
Adrien Béraud | b1bcdec | 2023-11-23 14:45:54 -0500 | [diff] [blame] | 26 | set(DEPENDENCIES_PATH ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/install/${TARGET}) |
| 27 | message("dependencies path: ${DEPENDENCIES_PATH}") |
Amna | 41d7662 | 2023-09-20 11:14:27 -0400 | [diff] [blame] | 28 | if (BUILD_DEPENDENCIES) |
Amna | e771190 | 2023-09-28 18:56:36 -0400 | [diff] [blame] | 29 | find_package(Python3 COMPONENTS Interpreter) |
| 30 | execute_process( |
| 31 | COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/dependencies/build.py |
| 32 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dependencies |
| 33 | ) |
Amna | 41d7662 | 2023-09-20 11:14:27 -0400 | [diff] [blame] | 34 | endif() |
Adrien Béraud | b1bcdec | 2023-11-23 14:45:54 -0500 | [diff] [blame] | 35 | include (GNUInstallDirs) |
| 36 | list(APPEND CMAKE_FIND_ROOT_PATH ${DEPENDENCIES_PATH}) |
| 37 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE BOTH) |
| 38 | list(APPEND CMAKE_PREFIX_PATH ${DEPENDENCIES_PATH}) |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 39 | find_package (PkgConfig REQUIRED) |
Amna | 2315830 | 2023-12-04 14:08:19 -0500 | [diff] [blame] | 40 | if(NOT BUILD_SHARED_LIBS) |
Adrien Béraud | b1bcdec | 2023-11-23 14:45:54 -0500 | [diff] [blame] | 41 | list(APPEND PKG_CONFIG_EXECUTABLE "--static") |
| 42 | endif() |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 43 | |
Amna | 366382f | 2023-10-02 16:37:02 -0400 | [diff] [blame] | 44 | check_include_file_cxx(msgpack.hpp HAVE_MSGPACKCXX) |
| 45 | if (NOT HAVE_MSGPACKCXX) |
| 46 | find_package(msgpack QUIET CONFIG NAMES msgpack msgpackc-cxx) |
| 47 | if (NOT msgpack_FOUND) |
| 48 | find_package(msgpack REQUIRED CONFIG NAMES msgpack-cxx) |
| 49 | set(MSGPACK_TARGET "msgpack-cxx") |
| 50 | else() |
| 51 | set(MSGPACK_TARGET "msgpackc-cxx") |
| 52 | endif() |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 53 | endif() |
Amna | 05eb28d | 2024-01-15 15:43:42 -0500 | [diff] [blame] | 54 | |
| 55 | if (BUILD_TOOLS) |
| 56 | find_package(yaml-cpp REQUIRED) |
| 57 | endif() |
| 58 | |
Amna | 4e52b16 | 2024-01-14 21:16:57 -0500 | [diff] [blame] | 59 | include_directories(${YAML_CPP_INCLUDE_DIR}) |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 60 | find_package(fmt) |
Amna | 41d7662 | 2023-09-20 11:14:27 -0400 | [diff] [blame] | 61 | pkg_search_module (opendht REQUIRED IMPORTED_TARGET opendht) |
| 62 | pkg_search_module (pjproject REQUIRED IMPORTED_TARGET libpjproject) |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 63 | else() |
| 64 | set (WIN32_DEP_DIR ${PROJECT_SOURCE_DIR}/../) |
| 65 | include_directories( |
| 66 | ${WIN32_DEP_DIR}/../msvc/include |
| 67 | ${WIN32_DEP_DIR}/msgpack-c/include |
| 68 | ${WIN32_DEP_DIR}/asio/asio/include |
| 69 | ${WIN32_DEP_DIR}/fmt/include |
| 70 | ${WIN32_DEP_DIR}/pjproject/pjlib/include |
| 71 | ${WIN32_DEP_DIR}/pjproject/pjlib-util/include |
| 72 | ${WIN32_DEP_DIR}/pjproject/pjnath/include |
| 73 | ${WIN32_DEP_DIR}/opendht/include |
| 74 | ${WIN32_DEP_DIR}/opendht/src/compat/msvc |
| 75 | ${WIN32_DEP_DIR}/openssl/include |
| 76 | ${WIN32_DEP_DIR}/restinio/dev |
| 77 | ${WIN32_DEP_DIR}/http_parser |
| 78 | ${WIN32_DEP_DIR}/pupnp/include |
| 79 | ${WIN32_DEP_DIR}/natpmp/include |
| 80 | ) |
| 81 | # windirent.h |
| 82 | include_directories(include/compat/msvc) |
| 83 | endif() |
| 84 | |
| 85 | if (NOT MSVC) |
| 86 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ |
| 87 | -DMSGPACK_NO_BOOST \ |
| 88 | -DMSGPACK_DISABLE_LEGACY_NIL \ |
| 89 | -DMSGPACK_DISABLE_LEGACY_CONVERT") |
| 90 | else() |
| 91 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ |
| 92 | -DGNUTLS_INTERNAL_BUILD \ |
| 93 | -D_USE_MATH_DEFINES \ |
| 94 | -D_SCL_SECURE_NO_WARNINGS \ |
| 95 | -D_CRT_SECURE_NO_WARNINGS \ |
| 96 | -D_WINSOCK_DEPRECATED_NO_WARNINGS \ |
| 97 | -DASIO_STANDALONE \ |
| 98 | -DWIN32_LEAN_AND_MEAN \ |
| 99 | -D_WIN32_WINNT=0x0601 \ |
| 100 | -DNATPMP_STATICLIB \ |
| 101 | -DMSGPACK_NO_BOOST \ |
| 102 | -DMSGPACK_DISABLE_LEGACY_NIL \ |
| 103 | -DMSGPACK_DISABLE_LEGACY_CONVERT \ |
| 104 | -DUNICODE \ |
| 105 | -D_UNICODE") |
| 106 | endif() |
Adrien Béraud | 370257c | 2023-08-15 20:53:09 -0400 | [diff] [blame] | 107 | |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 108 | # Sources |
| 109 | list (APPEND dhtnet_SOURCES |
| 110 | src/connectionmanager.cpp |
| 111 | src/ice_transport.cpp |
| 112 | src/multiplexed_socket.cpp |
| 113 | src/peer_connection.cpp |
| 114 | src/string_utils.cpp |
| 115 | src/fileutils.cpp |
Adrien Béraud | 80c14e1 | 2023-07-18 16:13:15 -0400 | [diff] [blame] | 116 | src/ip_utils.cpp |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 117 | src/security/tls_session.cpp |
| 118 | src/security/certstore.cpp |
| 119 | src/security/threadloop.cpp |
Adrien Béraud | 45dfac9 | 2023-07-19 00:08:50 -0400 | [diff] [blame] | 120 | src/security/diffie-hellman.cpp |
Adrien Béraud | a1d294f | 2023-07-17 22:42:13 -0400 | [diff] [blame] | 121 | src/turn/turn_cache.cpp |
| 122 | src/turn/turn_transport.cpp |
Morteza Namvar | 5f63952 | 2023-07-04 17:08:58 -0400 | [diff] [blame] | 123 | src/upnp/upnp_context.cpp |
| 124 | src/upnp/upnp_control.cpp |
| 125 | src/upnp/protocol/mapping.cpp |
Adrien Béraud | 80c14e1 | 2023-07-18 16:13:15 -0400 | [diff] [blame] | 126 | src/upnp/protocol/igd.cpp |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 127 | ) |
| 128 | |
| 129 | list (APPEND dhtnet_HEADERS |
Adrien Béraud | 149f29e | 2023-07-05 14:47:49 -0400 | [diff] [blame] | 130 | include/connectionmanager.h |
| 131 | include/multiplexed_socket.h |
| 132 | include/tls_session.h |
| 133 | include/certstore.h |
| 134 | include/ice_options.h |
Adrien Béraud | 6de3f88 | 2023-07-06 12:56:29 -0400 | [diff] [blame] | 135 | include/ice_transport.h |
Adrien Béraud | cb121f8 | 2023-07-08 09:18:39 -0400 | [diff] [blame] | 136 | include/ice_transport_factory.h |
Adrien Béraud | aa8c442 | 2023-07-07 11:40:36 -0400 | [diff] [blame] | 137 | include/ice_socket.h |
Adrien Béraud | 149f29e | 2023-07-05 14:47:49 -0400 | [diff] [blame] | 138 | include/fileutils.h |
| 139 | include/string_utils.h |
| 140 | include/ip_utils.h |
| 141 | include/upnp/mapping.h |
| 142 | include/upnp/upnp_context.h |
| 143 | include/upnp/upnp_control.h |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 144 | ) |
| 145 | |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 146 | # Port mapping dependencies - add sources and libraries |
| 147 | if (DHTNET_PUPNP AND NOT MSVC) |
Adrien Béraud | 370257c | 2023-08-15 20:53:09 -0400 | [diff] [blame] | 148 | pkg_search_module (upnp IMPORTED_TARGET upnp libupnp) |
| 149 | if (NOT upnp_FOUND) |
| 150 | message("libupnp not found: disabling") |
| 151 | set(DHTNET_PUPNP Off) |
Adrien Béraud | 6c6a962 | 2023-08-27 12:49:31 -0400 | [diff] [blame] | 152 | else() |
| 153 | set(upnp_LIBRARIES PkgConfig::upnp) |
Adrien Béraud | 0e6730e | 2023-08-29 14:12:52 -0400 | [diff] [blame] | 154 | set (requiresprivate "${requiresprivate} libupnp") |
Adrien Béraud | 370257c | 2023-08-15 20:53:09 -0400 | [diff] [blame] | 155 | endif() |
| 156 | endif() |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 157 | if (DHTNET_NATPMP AND NOT MSVC) |
Adrien Béraud | 370257c | 2023-08-15 20:53:09 -0400 | [diff] [blame] | 158 | pkg_search_module (natpmp IMPORTED_TARGET natpmp) |
| 159 | if (NOT natpmp_FOUND) |
| 160 | find_library(natpmp_LIBRARIES natpmp) |
| 161 | if (NOT natpmp_LIBRARIES) |
| 162 | message("NAT-PMP not found: disabling") |
| 163 | set(DHTNET_NATPMP Off) |
| 164 | else() |
| 165 | message("NAT-PMP found: ${natpmp_LIBRARIES}") |
Adrien Béraud | 0e6730e | 2023-08-29 14:12:52 -0400 | [diff] [blame] | 166 | set (libsprivate "${libsprivate} -lnatpmp") |
Adrien Béraud | 370257c | 2023-08-15 20:53:09 -0400 | [diff] [blame] | 167 | endif() |
| 168 | endif() |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 169 | endif() |
| 170 | |
| 171 | if (DHTNET_PUPNP) |
| 172 | list (APPEND dhtnet_PRIVATE_DEFS HAVE_LIBUPNP) |
| 173 | list (APPEND dhtnet_SOURCES |
| 174 | src/upnp/protocol/pupnp/pupnp.cpp |
| 175 | src/upnp/protocol/pupnp/upnp_igd.cpp |
| 176 | ) |
| 177 | list (APPEND dhtnet_PRIVATELIBS ${upnp_LIBRARIES}) |
| 178 | endif() |
| 179 | if (DHTNET_NATPMP) |
| 180 | list (APPEND dhtnet_PRIVATE_DEFS HAVE_LIBNATPMP) |
| 181 | list (APPEND dhtnet_SOURCES |
| 182 | src/upnp/protocol/natpmp/nat_pmp.cpp |
| 183 | src/upnp/protocol/natpmp/pmp_igd.cpp |
| 184 | ) |
| 185 | list (APPEND dhtnet_PRIVATELIBS ${natpmp_LIBRARIES}) |
Adrien Béraud | 370257c | 2023-08-15 20:53:09 -0400 | [diff] [blame] | 186 | endif() |
| 187 | |
Adrien Béraud | 612b55b | 2023-05-29 10:42:04 -0400 | [diff] [blame] | 188 | add_library(dhtnet ${dhtnet_SOURCES}) |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 189 | if (NOT MSVC) |
| 190 | target_link_libraries(dhtnet PUBLIC PkgConfig::opendht PkgConfig::pjproject fmt::fmt ${MSGPACK_LIB}) |
| 191 | else() |
| 192 | target_link_libraries(dhtnet PUBLIC |
| 193 | ${WIN32_DEP_DIR}/../msvc/lib/libopendht.lib |
| 194 | ${WIN32_DEP_DIR}/../msvc/lib/libpjproject.lib |
| 195 | ${WIN32_DEP_DIR}/../msvc/lib/libfmt.lib |
| 196 | ${WIN32_DEP_DIR}/../msvc/lib/libmsgpackc-cxx.lib) |
| 197 | endif() |
Amna | 366382f | 2023-10-02 16:37:02 -0400 | [diff] [blame] | 198 | if (NOT HAVE_MSGPACKCXX) |
Adrien Béraud | 62aefa6 | 2023-10-05 22:30:09 -0400 | [diff] [blame] | 199 | target_link_libraries(dhtnet PUBLIC ${MSGPACK_TARGET}) |
Amna | 366382f | 2023-10-02 16:37:02 -0400 | [diff] [blame] | 200 | endif() |
Adrien Béraud | 0627100 | 2023-07-27 15:52:29 -0400 | [diff] [blame] | 201 | if (APPLE) |
Adrien Béraud | 08548d9 | 2023-07-27 16:02:48 -0400 | [diff] [blame] | 202 | target_link_libraries(dhtnet PRIVATE "-framework CoreFoundation" "-framework Security" "resolv") |
Adrien Béraud | 0627100 | 2023-07-27 15:52:29 -0400 | [diff] [blame] | 203 | endif() |
| 204 | |
Adrien Béraud | 665d111 | 2023-06-01 19:03:57 -0400 | [diff] [blame] | 205 | target_include_directories(dhtnet PUBLIC |
| 206 | $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> |
| 207 | $<INSTALL_INTERFACE:include> |
| 208 | ) |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 209 | |
| 210 | target_compile_definitions(dhtnet PRIVATE ${dhtnet_PRIVATE_DEFS}) |
| 211 | target_link_libraries(dhtnet PRIVATE ${dhtnet_PRIVATELIBS}) |
| 212 | if (MSVC) |
| 213 | target_compile_definitions(dhtnet PRIVATE |
| 214 | _CRT_SECURE_NO_WARNINGS |
| 215 | _WINSOCK_DEPRECATED_NO_WARNINGS |
| 216 | ASIO_STANDALONE |
| 217 | _WIN32_WINNT=0x0601 |
| 218 | MSGPACK_NO_BOOST |
| 219 | MSGPACK_DISABLE_LEGACY_NIL |
| 220 | MSGPACK_DISABLE_LEGACY_CONVERT |
| 221 | DHTNET_STATIC |
| 222 | DHTNET_STATIC_DEFINE |
| 223 | DHTNET_EXPORTS |
| 224 | DHTNET_BUILDING |
| 225 | DHT) |
| 226 | target_compile_options(dhtnet PRIVATE |
| 227 | /O2; /Oi; ${DEFAULT_CXX_RUNTIME_LIBRARY}; /Gy; /MP; /Oy-; /sdl-; /W0; |
| 228 | /FC; /FS; /nologo; /Zi; /wd4996; /wd4503; /wd4180; /wd4244; /wd4267; |
| 229 | /Zc:__cplusplus; |
| 230 | ${DEFAULT_CXX_EXCEPTION_HANDLING}) |
| 231 | else() |
| 232 | target_compile_definitions(dhtnet PUBLIC PJ_AUTOCONF=1) |
Adrien Béraud | 370257c | 2023-08-15 20:53:09 -0400 | [diff] [blame] | 233 | endif() |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 234 | |
| 235 | if (BUILD_TESTING AND NOT MSVC) |
Adrien Béraud | 6b6a5d3 | 2023-08-15 15:53:33 -0400 | [diff] [blame] | 236 | target_compile_definitions(dhtnet PUBLIC DHTNET_TESTABLE) |
| 237 | endif() |
Adrien Béraud | a4030cd | 2023-06-21 09:35:40 -0400 | [diff] [blame] | 238 | |
| 239 | configure_file(dhtnet.pc.in dhtnet.pc @ONLY) |
| 240 | |
Adrien Béraud | a4030cd | 2023-06-21 09:35:40 -0400 | [diff] [blame] | 241 | # Install targets |
Adrien Béraud | 13e3343 | 2023-07-18 14:49:35 -0400 | [diff] [blame] | 242 | install(TARGETS dhtnet) |
Adrien Béraud | 149f29e | 2023-07-05 14:47:49 -0400 | [diff] [blame] | 243 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dhtnet) |
Adrien Béraud | 13e3343 | 2023-07-18 14:49:35 -0400 | [diff] [blame] | 244 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/dhtnet.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) |
Adrien Béraud | a4030cd | 2023-06-21 09:35:40 -0400 | [diff] [blame] | 245 | |
Andreas Traczyk | 24cc01e | 2023-08-23 18:55:15 -0400 | [diff] [blame] | 246 | if (BUILD_TOOLS AND NOT MSVC) |
Amna | 3876830 | 2023-08-21 11:51:56 -0400 | [diff] [blame] | 247 | add_executable(dnc |
| 248 | tools/dnc/main.cpp |
| 249 | tools/dnc/dnc.cpp |
Amna | 423b25b | 2024-02-06 13:21:19 -0500 | [diff] [blame] | 250 | tools/common.cpp |
| 251 | tools/dhtnet_crtmgr/dhtnet_crtmgr.cpp) |
Amna | 41848a2 | 2024-01-22 16:22:57 -0500 | [diff] [blame] | 252 | target_link_libraries(dnc PRIVATE dhtnet fmt::fmt yaml-cpp) |
Amna | 3876830 | 2023-08-21 11:51:56 -0400 | [diff] [blame] | 253 | target_include_directories(dnc PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools) |
| 254 | install(TARGETS dnc RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
Adrien Béraud | b75ab9d | 2023-08-23 09:26:58 -0400 | [diff] [blame] | 255 | |
Amna | 4a70f5c | 2023-09-14 17:32:05 -0400 | [diff] [blame] | 256 | add_executable(dsh |
| 257 | tools/dsh/main.cpp |
| 258 | tools/dsh/dsh.cpp |
Amna | 423b25b | 2024-02-06 13:21:19 -0500 | [diff] [blame] | 259 | tools/common.cpp |
| 260 | tools/dhtnet_crtmgr/dhtnet_crtmgr.cpp) |
Amna | 41848a2 | 2024-01-22 16:22:57 -0500 | [diff] [blame] | 261 | target_link_libraries(dsh PRIVATE dhtnet fmt::fmt yaml-cpp) |
Amna | 4e52b16 | 2024-01-14 21:16:57 -0500 | [diff] [blame] | 262 | target_include_directories(dsh PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools) |
Amna | 4a70f5c | 2023-09-14 17:32:05 -0400 | [diff] [blame] | 263 | install(TARGETS dsh RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 264 | |
Amna | 4e52b16 | 2024-01-14 21:16:57 -0500 | [diff] [blame] | 265 | add_executable(dvpn |
| 266 | tools/dvpn/main.cpp |
| 267 | tools/dvpn/dvpn.cpp |
Amna | 423b25b | 2024-02-06 13:21:19 -0500 | [diff] [blame] | 268 | tools/common.cpp |
| 269 | tools/dhtnet_crtmgr/dhtnet_crtmgr.cpp) |
Amna | 4e52b16 | 2024-01-14 21:16:57 -0500 | [diff] [blame] | 270 | target_link_libraries(dvpn PRIVATE dhtnet fmt::fmt yaml-cpp) |
| 271 | target_include_directories(dvpn PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools) |
| 272 | install(TARGETS dvpn RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 273 | |
Adrien Béraud | bd09c99 | 2023-09-20 11:55:37 -0400 | [diff] [blame] | 274 | find_library(READLINE_LIBRARIES readline) |
| 275 | find_path(READLINE_INCLUDE_DIR readline/readline.h) |
| 276 | add_library(readline STATIC IMPORTED) |
| 277 | set_target_properties(readline PROPERTIES |
| 278 | IMPORTED_LOCATION "${READLINE_LIBRARIES}" |
| 279 | INTERFACE_INCLUDE_DIRECTORIES "${READLINE_INCLUDE_DIR}") |
Adrien Béraud | b75ab9d | 2023-08-23 09:26:58 -0400 | [diff] [blame] | 280 | add_executable(upnpctrl |
| 281 | tools/upnp/upnpctrl.cpp) |
| 282 | target_link_libraries(upnpctrl PRIVATE dhtnet fmt::fmt readline) |
| 283 | target_include_directories(upnpctrl PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools) |
| 284 | install(TARGETS upnpctrl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
Amna | b10c6e7 | 2023-09-25 11:12:35 -0400 | [diff] [blame] | 285 | |
Amna | 423b25b | 2024-02-06 13:21:19 -0500 | [diff] [blame] | 286 | add_executable(dhtnet-crtmgr |
| 287 | tools/dhtnet_crtmgr/main.cpp |
| 288 | tools/dhtnet_crtmgr/dhtnet_crtmgr.cpp) |
| 289 | target_link_libraries(dhtnet-crtmgr PRIVATE dhtnet fmt::fmt) |
| 290 | target_include_directories(dhtnet-crtmgr PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools) |
| 291 | install(TARGETS dhtnet-crtmgr RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 292 | |
Amna | b10c6e7 | 2023-09-25 11:12:35 -0400 | [diff] [blame] | 293 | install(FILES |
| 294 | tools/dnc/dnc.1 |
| 295 | tools/dsh/dsh.1 |
| 296 | DESTINATION ${CMAKE_INSTALL_MANDIR}) |
Amna | 3876830 | 2023-08-21 11:51:56 -0400 | [diff] [blame] | 297 | endif() |
| 298 | |
Adrien Béraud | 6c6a962 | 2023-08-27 12:49:31 -0400 | [diff] [blame] | 299 | if (BUILD_BENCHMARKS) |
| 300 | add_executable(bench |
| 301 | tools/benchmark/main.cpp |
| 302 | tools/common.cpp) |
| 303 | target_link_libraries(bench PRIVATE dhtnet fmt::fmt) |
| 304 | target_include_directories(bench PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/tools) |
| 305 | install(TARGETS bench RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 306 | endif() |
| 307 | |
Adrien Béraud | efe2737 | 2023-05-27 18:56:29 -0400 | [diff] [blame] | 308 | if (BUILD_TESTING AND NOT MSVC) |
| 309 | pkg_search_module(Cppunit REQUIRED IMPORTED_TARGET cppunit) |
| 310 | add_executable(tests_certstore tests/certstore.cpp) |
| 311 | target_link_libraries(tests_certstore PRIVATE dhtnet fmt::fmt PkgConfig::Cppunit) |
| 312 | add_test(NAME tests_certstore COMMAND tests_certstore) |
| 313 | |
| 314 | add_executable(tests_connectionManager tests/connectionManager.cpp) |
| 315 | target_link_libraries(tests_connectionManager PRIVATE dhtnet fmt::fmt PkgConfig::Cppunit) |
| 316 | add_test(NAME tests_connectionManager COMMAND tests_connectionManager) |
| 317 | |
Adrien Béraud | 2a4e73d | 2023-08-27 12:53:55 -0400 | [diff] [blame] | 318 | add_executable(tests_fileutils tests/testFileutils.cpp) |
| 319 | target_link_libraries(tests_fileutils PRIVATE dhtnet fmt::fmt PkgConfig::Cppunit) |
| 320 | add_test(NAME tests_fileutils COMMAND tests_fileutils) |
Adrien Béraud | efe2737 | 2023-05-27 18:56:29 -0400 | [diff] [blame] | 321 | |
| 322 | #add_executable(tests_stringutils tests/testString_utils.cpp) |
| 323 | #target_link_libraries(tests_stringutils PRIVATE dhtnet fmt::fmt PkgConfig::Cppunit) |
| 324 | #add_test(NAME tests_stringutils COMMAND tests_stringutils) |
Adrien Béraud | a4030cd | 2023-06-21 09:35:40 -0400 | [diff] [blame] | 325 | endif() |