summaryrefslogtreecommitdiff
path: root/cmake/ipcp/udp.cmake
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2025-12-23 11:59:45 +0100
committerSander Vrijders <sander@ouroboros.rocks>2026-01-07 10:00:06 +0100
commit48c294105f5123dc876fbad199ec1e0166d82a18 (patch)
treec49ce8ac75a7d63c10ea1ff960eeff750c680a8e /cmake/ipcp/udp.cmake
parent145be13e8c18fcb39476d8f65fed23d82320f22f (diff)
downloadouroboros-48c294105f5123dc876fbad199ec1e0166d82a18.tar.gz
ouroboros-48c294105f5123dc876fbad199ec1e0166d82a18.zip
build: Refactor CMake modules
This moves the CMake build logic out of the source tree and splits it up into a more modular form. The tests now have a CMakeLists.txt file in their respective source directory. Signed-off-by: Dimitri Staessens <dimitri@ouroboros.rocks> Signed-off-by: Sander Vrijders <sander@ouroboros.rocks>
Diffstat (limited to 'cmake/ipcp/udp.cmake')
-rw-r--r--cmake/ipcp/udp.cmake51
1 files changed, 51 insertions, 0 deletions
diff --git a/cmake/ipcp/udp.cmake b/cmake/ipcp/udp.cmake
new file mode 100644
index 00000000..7195dfa1
--- /dev/null
+++ b/cmake/ipcp/udp.cmake
@@ -0,0 +1,51 @@
+set(UDP_SOURCE_DIR "${IPCP_SOURCE_DIR}/udp")
+
+set(IPCP_UDP4_TARGET ipcpd-udp4 CACHE INTERNAL "")
+set(IPCP_UDP6_TARGET ipcpd-udp6 CACHE INTERNAL "")
+
+set(IPCP_UDP_RD_THR 3 CACHE STRING
+ "Number of reader threads in UDP IPCPs")
+set(IPCP_UDP_WR_THR 3 CACHE STRING
+ "Number of writer threads in UDP IPCPs")
+set(IPCP_UDP_MPL 5000 CACHE STRING
+ "Default maximum packet lifetime for the UDP IPCPs, in ms")
+
+# Find nsupdate and nslookup for DDNS support
+find_program(NSUPDATE_EXECUTABLE
+ NAMES nsupdate
+ DOC "The nsupdate tool that enables DDNS")
+
+find_program(NSLOOKUP_EXECUTABLE
+ NAMES nslookup
+ DOC "The nslookup tool that resolves DNS names")
+
+mark_as_advanced(NSLOOKUP_EXECUTABLE NSUPDATE_EXECUTABLE)
+
+if (NSLOOKUP_EXECUTABLE AND NSUPDATE_EXECUTABLE)
+ set(DISABLE_DDNS FALSE CACHE BOOL "Disable DDNS support")
+ if (NOT DISABLE_DDNS)
+ message(STATUS "DDNS support enabled")
+ set(HAVE_DDNS TRUE CACHE INTERNAL "")
+ else ()
+ message(STATUS "DDNS support disabled by user")
+ unset(HAVE_DDNS CACHE)
+ endif ()
+else ()
+ if (NSLOOKUP_EXECUTABLE)
+ message(STATUS "Install nsupdate to enable DDNS support")
+ elseif (NSUPDATE_EXECUTABLE)
+ message(STATUS "Install nslookup to enable DDNS support")
+ else ()
+ message(STATUS "Install nslookup and nsupdate to enable DDNS support")
+ endif ()
+endif ()
+
+add_executable(${IPCP_UDP4_TARGET} "${UDP_SOURCE_DIR}/udp4.c" ${IPCP_SOURCES})
+add_executable(${IPCP_UDP6_TARGET} "${UDP_SOURCE_DIR}/udp6.c" ${IPCP_SOURCES})
+
+foreach(target ${IPCP_UDP4_TARGET} ${IPCP_UDP6_TARGET})
+ target_include_directories(${target} PRIVATE ${IPCP_INCLUDE_DIRS})
+ target_link_libraries(${target} PUBLIC ouroboros-dev)
+endforeach()
+
+install(TARGETS ${IPCP_UDP4_TARGET} ${IPCP_UDP6_TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})