summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/OuroborosConfig.cmake.in23
-rw-r--r--cmake/compiler.cmake38
-rw-r--r--cmake/config/global.cmake45
-rw-r--r--cmake/config/ipcp/broadcast.cmake4
-rw-r--r--cmake/config/ipcp/common.cmake43
-rw-r--r--cmake/config/ipcp/eth.cmake15
-rw-r--r--cmake/config/ipcp/local.cmake7
-rw-r--r--cmake/config/ipcp/udp.cmake9
-rw-r--r--cmake/config/ipcp/unicast.cmake12
-rw-r--r--cmake/config/irmd.cmake36
-rw-r--r--cmake/config/lib.cmake (renamed from cmake/lib/lib.cmake)46
-rw-r--r--cmake/config/ssm.cmake (renamed from cmake/lib/ssm.cmake)20
-rw-r--r--cmake/config/tests.cmake17
-rw-r--r--cmake/dependencies.cmake54
-rw-r--r--cmake/dependencies/coverage/gcov.cmake21
-rw-r--r--cmake/dependencies/coverage/lcov.cmake (renamed from cmake/dependencies/lcov.cmake)18
-rw-r--r--cmake/dependencies/crypt/libgcrypt.cmake55
-rw-r--r--cmake/dependencies/crypt/openssl.cmake (renamed from cmake/dependencies/openssl.cmake)29
-rw-r--r--cmake/dependencies/eth/bpf.cmake (renamed from cmake/dependencies/bpf.cmake)14
-rw-r--r--cmake/dependencies/eth/netmap.cmake (renamed from cmake/dependencies/netmap.cmake)10
-rw-r--r--cmake/dependencies/eth/rawsockets.cmake (renamed from cmake/dependencies/rawsockets.cmake)10
-rw-r--r--cmake/dependencies/explicit_bzero.cmake1
-rw-r--r--cmake/dependencies/fuse.cmake23
-rw-r--r--cmake/dependencies/gcov.cmake11
-rw-r--r--cmake/dependencies/irmd/libtoml.cmake29
-rw-r--r--cmake/dependencies/libgcrypt.cmake31
-rw-r--r--cmake/dependencies/libtoml.cmake5
-rw-r--r--cmake/dependencies/sysrandom.cmake21
-rw-r--r--cmake/dependencies/system/explicit_bzero.cmake4
-rw-r--r--cmake/dependencies/system/fuse.cmake44
-rw-r--r--cmake/dependencies/system/libraries.cmake17
-rw-r--r--cmake/dependencies/system/protobufc.cmake (renamed from cmake/dependencies/protobufc.cmake)10
-rw-r--r--cmake/dependencies/system/robustmutex.cmake (renamed from cmake/dependencies/robustmutex.cmake)10
-rw-r--r--cmake/dependencies/system/sysrandom.cmake14
-rw-r--r--cmake/dependencies/systemlibraries.cmake20
-rw-r--r--cmake/dependencies/udp/ddns.cmake31
-rw-r--r--cmake/doc.cmake14
-rw-r--r--cmake/include.cmake8
-rw-r--r--cmake/install.cmake87
-rw-r--r--cmake/ipcp.cmake10
-rw-r--r--cmake/ipcp/broadcast.cmake28
-rw-r--r--cmake/ipcp/eth.cmake48
-rw-r--r--cmake/ipcp/ipcp.cmake60
-rw-r--r--cmake/ipcp/local.cmake28
-rw-r--r--cmake/ipcp/udp.cmake57
-rw-r--r--cmake/ipcp/unicast.cmake56
-rw-r--r--cmake/irmd.cmake126
-rw-r--r--cmake/lib.cmake11
-rw-r--r--cmake/lib/common.cmake124
-rw-r--r--cmake/lib/dev.cmake37
-rw-r--r--cmake/lib/irm.cmake34
-rw-r--r--cmake/package.cmake12
-rw-r--r--cmake/tests.cmake30
-rw-r--r--cmake/tools.cmake8
-rw-r--r--cmake/tools/irm.cmake33
-rw-r--r--cmake/tools/obc.cmake4
-rw-r--r--cmake/tools/ocbr.cmake4
-rw-r--r--cmake/tools/oecho.cmake4
-rw-r--r--cmake/tools/operf.cmake4
-rw-r--r--cmake/tools/oping.cmake4
-rw-r--r--cmake/tools/ovpn.cmake6
-rw-r--r--cmake/tools/tools.cmake8
-rw-r--r--cmake/utils/AddCompileFlags.cmake21
-rw-r--r--cmake/utils/CMakeUninstall.cmake.in36
-rw-r--r--cmake/utils/CompilerUtils.cmake10
-rw-r--r--cmake/utils/DebugTargets.cmake16
-rw-r--r--cmake/utils/DisableTestLogging.cmake23
-rw-r--r--cmake/utils/FindProtobufC.cmake36
-rw-r--r--cmake/utils/GenCoverage.cmake6
-rw-r--r--cmake/utils/TestUtils.cmake34
70 files changed, 752 insertions, 1072 deletions
diff --git a/cmake/OuroborosConfig.cmake.in b/cmake/OuroborosConfig.cmake.in
new file mode 100644
index 00000000..41ff7fdd
--- /dev/null
+++ b/cmake/OuroborosConfig.cmake.in
@@ -0,0 +1,23 @@
+# Ouroboros CMake Package Configuration
+#
+# This file allows other CMake projects to find and use Ouroboros libraries
+# via find_package(Ouroboros).
+#
+# Exported targets:
+# Ouroboros::dev - Development library (libouroboros-dev)
+# Ouroboros::irm - IRM management library (libouroboros-irm)
+#
+# Example usage:
+# find_package(Ouroboros REQUIRED)
+# target_link_libraries(myapp Ouroboros::dev)
+
+@PACKAGE_INIT@
+
+include(CMakeFindDependencyMacro)
+
+# Required dependencies for Ouroboros libraries
+find_dependency(Threads)
+
+include("${CMAKE_CURRENT_LIST_DIR}/OuroborosTargets.cmake")
+
+check_required_components(Ouroboros)
diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake
index 6258cca0..5d452e02 100644
--- a/cmake/compiler.cmake
+++ b/cmake/compiler.cmake
@@ -31,42 +31,34 @@ test_and_set_c_compiler_flag_global(-Wdeclaration-after-statement)
test_and_set_c_compiler_flag_global(-Winfinite-recursion)
test_and_set_c_compiler_flag_global(-fmax-errors=5)
-set(DISABLE_COVERAGE ON CACHE BOOL "Disable code coverage analysis")
-
-if (NOT DISABLE_COVERAGE)
- test_and_set_c_compiler_flag_global(-g)
- test_and_set_c_compiler_flag_global(--coverage)
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
- set(ENABLE_COVERAGE ON)
-else()
- set(ENABLE_COVERAGE OFF)
-endif()
-
-if (NOT CMAKE_BUILD_TYPE)
+if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
"Build type (Release, Debug, DebugASan, DebugTSan, DebugLSan, DebugUSan, DebugAnalyzer)" FORCE)
endif()
-if (CMAKE_BUILD_TYPE STREQUAL "Release")
+if(CMAKE_BUILD_TYPE STREQUAL "Release")
test_and_set_c_compiler_flag_global(-O3)
-elseif (CMAKE_BUILD_TYPE STREQUAL "Debug")
+elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
test_and_set_c_compiler_flag_global(-g)
-elseif (CMAKE_BUILD_TYPE STREQUAL "DebugASan")
+elseif(CMAKE_BUILD_TYPE STREQUAL "DebugASan")
test_and_set_c_compiler_flag_global(-g)
test_and_set_c_compiler_flag_global(-fsanitize=address)
-elseif (CMAKE_BUILD_TYPE STREQUAL "DebugTSan")
+ add_link_options(-fsanitize=address)
+elseif(CMAKE_BUILD_TYPE STREQUAL "DebugTSan")
test_and_set_c_compiler_flag_global(-g)
test_and_set_c_compiler_flag_global(-fsanitize=thread)
-elseif (CMAKE_BUILD_TYPE STREQUAL "DebugLSan")
+ add_link_options(-fsanitize=thread)
+elseif(CMAKE_BUILD_TYPE STREQUAL "DebugLSan")
test_and_set_c_compiler_flag_global(-g)
test_and_set_c_compiler_flag_global(-fsanitize=leak)
-elseif (CMAKE_BUILD_TYPE STREQUAL "DebugUSan")
+ add_link_options(-fsanitize=leak)
+elseif(CMAKE_BUILD_TYPE STREQUAL "DebugUSan")
test_and_set_c_compiler_flag_global(-g)
test_and_set_c_compiler_flag_global(-fsanitize=undefined)
-elseif (CMAKE_BUILD_TYPE STREQUAL "DebugAnalyzer")
+ add_link_options(-fsanitize=undefined)
+elseif(CMAKE_BUILD_TYPE STREQUAL "DebugAnalyzer")
test_and_set_c_compiler_flag_global(-g)
test_and_set_c_compiler_flag_global(-fanalyzer)
-else ()
- message(FATAL_ERROR "Unkown build type ${CMAKE_BUILD_TYPE}")
-endif ()
+else()
+ message(FATAL_ERROR "Unknown build type ${CMAKE_BUILD_TYPE}")
+endif()
diff --git a/cmake/config/global.cmake b/cmake/config/global.cmake
new file mode 100644
index 00000000..243e1ba0
--- /dev/null
+++ b/cmake/config/global.cmake
@@ -0,0 +1,45 @@
+# Global configuration options for Ouroboros
+# These options affect the entire framework
+
+# Installation directories
+set(OUROBOROS_CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/ouroboros" CACHE PATH
+ "Configuration directory")
+
+# Security directories
+set(OUROBOROS_SECURITY_DIR "${OUROBOROS_CONFIG_DIR}/security" CACHE PATH
+ "Security directory holding authentication information")
+set(OUROBOROS_CA_CRT_DIR "${OUROBOROS_SECURITY_DIR}/cacert" CACHE PATH
+ "Directory holding trusted CA certificates")
+set(OUROBOROS_SRV_CRT_DIR "${OUROBOROS_SECURITY_DIR}/server" CACHE PATH
+ "Directory holding server certificates")
+set(OUROBOROS_CLI_CRT_DIR "${OUROBOROS_SECURITY_DIR}/client" CACHE PATH
+ "Directory holding client certificates")
+set(OUROBOROS_UNTRUSTED_DIR "${OUROBOROS_SECURITY_DIR}/untrusted" CACHE PATH
+ "Directory holding untrusted intermediate certificates")
+
+# Shared memory naming
+set(SHM_PREFIX "ouroboros" CACHE STRING
+ "String to prepend to POSIX shared memory filenames")
+set(SHM_LOCKFILE_NAME "/${SHM_PREFIX}.lockfile" CACHE INTERNAL
+ "Filename for the POSIX shared memory lockfile")
+
+# FUSE configuration
+if(HAVE_FUSE)
+ set(FUSE_PREFIX "/tmp/ouroboros" CACHE STRING
+ "Mountpoint for RIB filesystem")
+endif()
+
+# Secure memory configuration
+set(IRMD_SECMEM_MAX 1048576 CACHE STRING "IRMd secure heap size")
+set(PROC_SECMEM_MAX 1048576 CACHE STRING "Process secure heap size")
+set(SECMEM_GUARD 32 CACHE STRING "Secure heap min size")
+
+# Container/deployment options
+set(BUILD_CONTAINER FALSE CACHE BOOL
+ "Disable thread priority setting for container compatibility")
+set(DISABLE_CORE_LOCK TRUE CACHE BOOL
+ "Disable locking performance threads to a core")
+
+# IPC socket configuration
+set(SOCK_BUF_SIZE 10240 CACHE STRING
+ "Size of the buffer used by the UNIX sockets for local IPC")
diff --git a/cmake/config/ipcp/broadcast.cmake b/cmake/config/ipcp/broadcast.cmake
new file mode 100644
index 00000000..3c4d98da
--- /dev/null
+++ b/cmake/config/ipcp/broadcast.cmake
@@ -0,0 +1,4 @@
+# Broadcast IPCP configuration options for Ouroboros
+
+set(IPCP_BROADCAST_MPL 100 CACHE STRING
+ "Default maximum packet lifetime for the Broadcast IPCP, in ms")
diff --git a/cmake/config/ipcp/common.cmake b/cmake/config/ipcp/common.cmake
new file mode 100644
index 00000000..ffd5dc32
--- /dev/null
+++ b/cmake/config/ipcp/common.cmake
@@ -0,0 +1,43 @@
+# Common IPCP configuration options for Ouroboros
+# Options affecting all IPC Process types
+
+# Connection manager
+set(CONNMGR_RCV_TIMEOUT 1000 CACHE STRING
+ "Timeout for the connection manager to wait for OCEP info (ms).")
+
+# Debugging
+set(IPCP_DEBUG_LOCAL FALSE CACHE BOOL
+ "Use PID as address for local debugging")
+
+# QoS cube priorities (0-99, higher = more priority)
+set(IPCP_QOS_CUBE_BE_PRIO 50 CACHE STRING
+ "Priority for best effort QoS cube (0-99)")
+set(IPCP_QOS_CUBE_VIDEO_PRIO 90 CACHE STRING
+ "Priority for video QoS cube (0-99)")
+set(IPCP_QOS_CUBE_VOICE_PRIO 99 CACHE STRING
+ "Priority for voice QoS cube (0-99)")
+
+# Validate QoS cube priorities
+if((IPCP_QOS_CUBE_BE_PRIO LESS 0) OR (IPCP_QOS_CUBE_BE_PRIO GREATER 99))
+ message(FATAL_ERROR "Invalid priority for best effort QoS cube (must be 0-99)")
+endif()
+if((IPCP_QOS_CUBE_VIDEO_PRIO LESS 0) OR (IPCP_QOS_CUBE_VIDEO_PRIO GREATER 99))
+ message(FATAL_ERROR "Invalid priority for video QoS cube (must be 0-99)")
+endif()
+if((IPCP_QOS_CUBE_VOICE_PRIO LESS 0) OR (IPCP_QOS_CUBE_VOICE_PRIO GREATER 99))
+ message(FATAL_ERROR "Invalid priority for voice QoS cube (must be 0-99)")
+endif()
+
+# Threading
+set(IPCP_MIN_THREADS 4 CACHE STRING
+ "Minimum number of worker threads in the IPCP")
+set(IPCP_ADD_THREADS 4 CACHE STRING
+ "Number of extra threads to start when an IPCP faces thread starvation")
+set(IPCP_SCHED_THR_MUL 2 CACHE STRING
+ "Number of scheduler threads per QoS cube")
+
+# Linux-specific
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(IPCP_LINUX_TIMERSLACK_NS 100 CACHE STRING
+ "Slack value for high resolution timers on Linux systems.")
+endif()
diff --git a/cmake/config/ipcp/eth.cmake b/cmake/config/ipcp/eth.cmake
new file mode 100644
index 00000000..2f50d24d
--- /dev/null
+++ b/cmake/config/ipcp/eth.cmake
@@ -0,0 +1,15 @@
+# Ethernet IPCP configuration options for Ouroboros
+# Options for eth-llc and eth-dix IPCPs
+
+set(IPCP_ETH_RD_THR 1 CACHE STRING
+ "Number of reader threads in Ethernet IPCP")
+set(IPCP_ETH_WR_THR 1 CACHE STRING
+ "Number of writer threads in Ethernet IPCP")
+set(IPCP_ETH_QDISC_BYPASS false CACHE BOOL
+ "Bypass the Qdisc in the kernel when using raw sockets")
+set(IPCP_ETH_LO_MTU 9000 CACHE STRING
+ "Restrict Ethernet MTU over loopback interfaces")
+set(IPCP_ETH_MGMT_FRAME_SIZE 9000 CACHE STRING
+ "Management frame buffer size for Ethernet IPCPs")
+set(IPCP_ETH_MPL 100 CACHE STRING
+ "Default maximum packet lifetime for the Ethernet IPCPs, in ms")
diff --git a/cmake/config/ipcp/local.cmake b/cmake/config/ipcp/local.cmake
new file mode 100644
index 00000000..df47c45b
--- /dev/null
+++ b/cmake/config/ipcp/local.cmake
@@ -0,0 +1,7 @@
+# Local IPCP configuration options for Ouroboros
+
+set(IPCP_LOCAL_MPL 100 CACHE STRING
+ "Default maximum packet lifetime for the Local IPCP, in ms")
+
+set(IPCP_LOCAL_POLLING FALSE CACHE BOOL
+ "Enable active polling in the Local IPCP for low-latency mode")
diff --git a/cmake/config/ipcp/udp.cmake b/cmake/config/ipcp/udp.cmake
new file mode 100644
index 00000000..691948ab
--- /dev/null
+++ b/cmake/config/ipcp/udp.cmake
@@ -0,0 +1,9 @@
+# UDP IPCP configuration options for Ouroboros
+# Options for udp4 and udp6 IPCPs
+
+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")
diff --git a/cmake/config/ipcp/unicast.cmake b/cmake/config/ipcp/unicast.cmake
new file mode 100644
index 00000000..905c661a
--- /dev/null
+++ b/cmake/config/ipcp/unicast.cmake
@@ -0,0 +1,12 @@
+# Unicast IPCP configuration options for Ouroboros
+
+set(IPCP_UNICAST_MPL 100 CACHE STRING
+ "Default maximum packet lifetime for the Unicast IPCP, in ms")
+set(PFT_SIZE 256 CACHE STRING
+ "Prefix forwarding table size for the Unicast IPCP")
+
+# Protocol debugging
+set(DEBUG_PROTO_DHT FALSE CACHE BOOL
+ "Add DHT protocol debug logging")
+set(DEBUG_PROTO_LS FALSE CACHE BOOL
+ "Add link state protocol debug logging")
diff --git a/cmake/config/irmd.cmake b/cmake/config/irmd.cmake
new file mode 100644
index 00000000..9795e4a4
--- /dev/null
+++ b/cmake/config/irmd.cmake
@@ -0,0 +1,36 @@
+# IRMd configuration options for Ouroboros
+# Options affecting the IPC Resource Manager daemon
+
+# Timeouts (all in milliseconds unless noted)
+set(IRMD_REQ_ARR_TIMEOUT 1000 CACHE STRING
+ "Timeout for an application to respond to a new flow (ms)")
+set(BOOTSTRAP_TIMEOUT 5000 CACHE STRING
+ "Timeout for an IPCP to bootstrap (ms)")
+set(ENROLL_TIMEOUT 20000 CACHE STRING
+ "Timeout for an IPCP to enroll (ms)")
+set(REG_TIMEOUT 20000 CACHE STRING
+ "Timeout for registering a name (ms)")
+set(QUERY_TIMEOUT 200 CACHE STRING
+ "Timeout to query a name with an IPCP (ms)")
+set(CONNECT_TIMEOUT 20000 CACHE STRING
+ "Timeout to connect an IPCP to another IPCP (ms)")
+set(FLOW_ALLOC_TIMEOUT 20000 CACHE STRING
+ "Timeout for a flow allocation response (ms)")
+
+# OAP (Ouroboros Authentication Protocol)
+set(OAP_REPLAY_TIMER 20 CACHE STRING
+ "OAP replay protection window (s)")
+set(DEBUG_PROTO_OAP FALSE CACHE BOOL
+ "Add Flow allocation protocol message output to IRMd debug logging")
+
+# Threading
+set(IRMD_MIN_THREADS 8 CACHE STRING
+ "Minimum number of worker threads in the IRMd")
+set(IRMD_ADD_THREADS 8 CACHE STRING
+ "Number of extra threads to start when the IRMD faces thread starvation")
+
+# Process management
+set(IRMD_PKILL_TIMEOUT 30 CACHE STRING
+ "Number of seconds to wait before sending SIGKILL to subprocesses on exit")
+set(IRMD_KILL_ALL_PROCESSES TRUE CACHE BOOL
+ "Kill all processes on exit")
diff --git a/cmake/lib/lib.cmake b/cmake/config/lib.cmake
index 86b4418c..287f30dc 100644
--- a/cmake/lib/lib.cmake
+++ b/cmake/config/lib.cmake
@@ -1,7 +1,7 @@
-set(LIB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/lib")
-set(LIB_BINARY_DIR "${CMAKE_BINARY_DIR}/src/lib")
+# Library configuration options for Ouroboros
+# Options affecting libouroboros-common, libouroboros-dev, libouroboros-irm
-# Library configuration variables
+# Flow limits
set(SYS_MAX_FLOWS 10240 CACHE STRING
"Maximum number of total flows for this system")
set(PROG_MAX_FLOWS 4096 CACHE STRING
@@ -11,29 +11,32 @@ set(PROG_RES_FDS 64 CACHE STRING
set(PROG_MAX_FQUEUES 32 CACHE STRING
"Maximum number of flow sets per application")
-if (NOT APPLE)
+# Threading
+if(NOT APPLE)
set(PTHREAD_COND_CLOCK "CLOCK_MONOTONIC" CACHE STRING
"Clock to use for condition variable timing")
-else ()
+else()
set(PTHREAD_COND_CLOCK "CLOCK_REALTIME" CACHE INTERNAL
"Clock to use for condition variable timing")
-endif ()
+endif()
+# Timeouts
set(SOCKET_TIMEOUT 500 CACHE STRING
"Default timeout for responses from IPCPs (ms)")
-set(SHM_PREFIX "ouroboros" CACHE STRING
- "String to prepend to POSIX shared memory filenames")
-set(SHM_LOCKFILE_NAME "/${SHM_PREFIX}.lockfile" CACHE INTERNAL
- "Filename for the POSIX shared memory lockfile")
+# QoS settings
set(QOS_DISABLE_CRC TRUE CACHE BOOL
"Ignores ber setting on all QoS cubes")
+
+# Delta-t protocol timers
set(DELTA_T_MPL 60 CACHE STRING
"Maximum packet lifetime (s)")
set(DELTA_T_ACK 10 CACHE STRING
"Maximum time to acknowledge a packet (s)")
set(DELTA_T_RTX 120 CACHE STRING
"Maximum time to retransmit a packet (s)")
+
+# FRCT configuration
set(FRCT_REORDER_QUEUE_SIZE 256 CACHE STRING
"Size of the reordering queue, must be a power of 2")
set(FRCT_START_WINDOW 64 CACHE STRING
@@ -48,6 +51,8 @@ set(FRCT_RTO_MIN 250 CACHE STRING
"Minimum Retransmission Timeout (RTO) for FRCT (us)")
set(FRCT_TICK_TIME 5000 CACHE STRING
"Tick time for FRCT activity (retransmission, acknowledgments) (us)")
+
+# Retransmission (RXM) configuration
set(RXM_BUFFER_ON_HEAP FALSE CACHE BOOL
"Store packets for retransmission on the heap instead of in packet buffer")
set(RXM_BLOCKING TRUE CACHE BOOL
@@ -60,23 +65,30 @@ set(RXM_WHEEL_LEVELS 3 CACHE STRING
"Number of levels in the retransmission wheel")
set(RXM_WHEEL_SLOTS_PER_LEVEL 256 CACHE STRING
"Number of slots per level in the retransmission wheel, must be a power of 2")
+
+# Acknowledgment wheel configuration
set(ACK_WHEEL_SLOTS 256 CACHE STRING
"Number of slots in the acknowledgment wheel, must be a power of 2")
set(ACK_WHEEL_RESOLUTION 18 CACHE STRING
"Minimum acknowledgment delay (ns), as a power to 2")
+
+# Thread pool manager (TPM) debugging
set(TPM_DEBUG_REPORT_INTERVAL 0 CACHE STRING
"Interval at wich the TPM will report long running threads (s), 0 disables")
set(TPM_DEBUG_ABORT_TIMEOUT 0 CACHE STRING
"TPM abort process after a thread reaches this timeout (s), 0 disables")
+
+# Encryption
set(KEY_ROTATION_BIT 20 CACHE STRING
"Bit position in packet counter that triggers key rotation (default 20 = every 2^20 packets)")
-if (HAVE_FUSE)
+# Flow statistics (requires FUSE)
+if(HAVE_FUSE)
set(PROC_FLOW_STATS TRUE CACHE BOOL
"Enable flow statistics tracking for application flows")
- if (PROC_FLOW_STATS)
- message(STATUS "Application flow statistics enabled")
- else ()
- message(STATUS "Application flow statistics disabled")
- endif ()
-endif ()
+ if(PROC_FLOW_STATS)
+ message(STATUS "Application flow statistics enabled")
+ else()
+ message(STATUS "Application flow statistics disabled")
+ endif()
+endif()
diff --git a/cmake/lib/ssm.cmake b/cmake/config/ssm.cmake
index 8a2971e6..c1f34655 100644
--- a/cmake/lib/ssm.cmake
+++ b/cmake/config/ssm.cmake
@@ -1,18 +1,18 @@
-# Pool size configuration for Ouroboros secure shared memory
-# This file defines the allocation parameters for the
-# secure shared memory pool allocator
+# Secure Shared Memory (SSM) pool configuration for Ouroboros
+# This file defines the allocation parameters for the secure shared memory
+# pool allocator
# Shared memory pool naming configuration
set(SSM_PREFIX "ouroboros" CACHE STRING
"Prefix for secure shared memory pools")
-# Pool naming
+# Pool naming (internal)
set(SSM_GSPP_NAME "/${SSM_PREFIX}.gspp" CACHE INTERNAL
"Name for the Global Shared Packet Pool")
set(SSM_PUP_NAME_FMT "/${SSM_PREFIX}.pup.%d" CACHE INTERNAL
"Format string for Per-User Pool names (uid as argument)")
-# Legacy naming (for compatibility)
+# Packet buffer configuration
set(SSM_POOL_NAME "/${SHM_PREFIX}.pool" CACHE INTERNAL
"Name for the main POSIX shared memory pool")
set(SSM_POOL_BLOCKS 16384 CACHE STRING
@@ -74,11 +74,9 @@ set(SSM_PUP_256K_BLOCKS 2 CACHE STRING
set(SSM_PUP_1M_BLOCKS 0 CACHE STRING
"PUP: Number of 1MB blocks")
-# SSM packet buffer overhead - computed at compile time via sizeof()
-# Defined in config.h.in as sizeof(_ssm_memory_block) + sizeof(_ssm_pk_buff)
-# This makes it portable across platforms with different pid_t sizes
+# SSM pool size calculations
+include(utils/HumanReadable)
-# GSPP total size calculation
math(EXPR SSM_GSPP_TOTAL_SIZE
"(1 << 8) * ${SSM_GSPP_256_BLOCKS} + \
(1 << 9) * ${SSM_GSPP_512_BLOCKS} + \
@@ -93,7 +91,6 @@ math(EXPR SSM_GSPP_TOTAL_SIZE
set(SSM_GSPP_TOTAL_SIZE ${SSM_GSPP_TOTAL_SIZE} CACHE INTERNAL
"GSPP total size in bytes")
-# PUP total size calculation
math(EXPR SSM_PUP_TOTAL_SIZE
"(1 << 8) * ${SSM_PUP_256_BLOCKS} + \
(1 << 9) * ${SSM_PUP_512_BLOCKS} + \
@@ -108,15 +105,12 @@ math(EXPR SSM_PUP_TOTAL_SIZE
set(SSM_PUP_TOTAL_SIZE ${SSM_PUP_TOTAL_SIZE} CACHE INTERNAL
"PUP total size in bytes")
-# Legacy total size (same as GSPP)
set(SSM_POOL_TOTAL_SIZE ${SSM_GSPP_TOTAL_SIZE} CACHE INTERNAL
"Total shared memory pool size in bytes")
-include(utils/HumanReadable)
format_bytes_human_readable(${SSM_GSPP_TOTAL_SIZE} SSM_GSPP_SIZE_DISPLAY)
format_bytes_human_readable(${SSM_PUP_TOTAL_SIZE} SSM_PUP_SIZE_DISPLAY)
-# Display configuration summary
message(STATUS "Secure Shared Memory Pool Configuration:")
message(STATUS " Pool prefix: ${SSM_PREFIX}")
message(STATUS " Size classes: "
diff --git a/cmake/config/tests.cmake b/cmake/config/tests.cmake
new file mode 100644
index 00000000..24730989
--- /dev/null
+++ b/cmake/config/tests.cmake
@@ -0,0 +1,17 @@
+# Test configuration options
+
+set(DISABLE_TESTS_LOGGING TRUE CACHE BOOL
+ "Disable Ouroboros log output in tests")
+if(DISABLE_TESTS_LOGGING)
+ message(STATUS "Ouroboros logging in test output disabled")
+else()
+ message(STATUS "Ouroboros logging in test output enabled")
+endif()
+
+set(DISABLE_TESTS_CORE_DUMPS TRUE CACHE BOOL
+ "Enable core dumps for tests (useful for debugging)")
+if(DISABLE_TESTS_CORE_DUMPS)
+ message(STATUS "Core dumps in tests enabled")
+else()
+ message(STATUS "Core dumps in tests disabled")
+endif()
diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake
index 4c999250..109fe1d6 100644
--- a/cmake/dependencies.cmake
+++ b/cmake/dependencies.cmake
@@ -1,19 +1,43 @@
-include(FindPkgConfig)
+find_package(PkgConfig QUIET)
include(CheckSymbolExists)
-include(dependencies/protobufc)
-include(dependencies/explicit_bzero)
-include(dependencies/systemlibraries)
-include(dependencies/robustmutex)
-include(dependencies/fuse)
-include(dependencies/libgcrypt)
-include(dependencies/openssl)
-include(dependencies/sysrandom)
-include(dependencies/libtoml)
-include(dependencies/rawsockets)
-include(dependencies/bpf)
-include(dependencies/netmap)
-include(dependencies/gcov)
-include(dependencies/lcov)
+# System libraries and features
+include(dependencies/system/protobufc)
+include(dependencies/system/libraries)
+include(dependencies/system/explicit_bzero)
+include(dependencies/system/robustmutex)
+include(dependencies/system/fuse)
+include(dependencies/system/sysrandom)
+
+# Cryptography
+include(dependencies/crypt/openssl)
+include(dependencies/crypt/libgcrypt)
+
+# IRMd
+include(dependencies/irmd/libtoml)
+
+# Ethernet IPCP backends
+include(dependencies/eth/rawsockets)
+include(dependencies/eth/bpf)
+include(dependencies/eth/netmap)
+if(HAVE_RAW_SOCKETS OR HAVE_BPF OR HAVE_NETMAP)
+ set(HAVE_ETH TRUE CACHE INTERNAL "Ethernet IPCP support available")
+else()
+ unset(HAVE_ETH CACHE)
+endif()
+
+# UDP IPCP
+include(dependencies/udp/ddns)
+
+# Coverage tools
+include(dependencies/coverage/gcov)
+include(dependencies/coverage/lcov)
+
+# Validate that at least one secure random generator is available
+if(NOT ((CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") OR APPLE OR
+ HAVE_SYS_RANDOM OR HAVE_OPENSSL_RNG OR HAVE_LIBGCRYPT))
+ message(FATAL_ERROR "No secure random generator found, "
+ "please install libgcrypt (> 1.7.0) or OpenSSL")
+endif()
diff --git a/cmake/dependencies/coverage/gcov.cmake b/cmake/dependencies/coverage/gcov.cmake
new file mode 100644
index 00000000..1b593155
--- /dev/null
+++ b/cmake/dependencies/coverage/gcov.cmake
@@ -0,0 +1,21 @@
+include(utils/CompilerUtils)
+
+find_program(GCOV_PATH gcov)
+
+if(GCOV_PATH)
+ set(HAVE_GCOV TRUE CACHE INTERNAL "gcov coverage tool available")
+ set(DISABLE_COVERAGE ON CACHE BOOL "Disable code coverage analysis")
+ if(DISABLE_COVERAGE)
+ message(STATUS "gcov found - coverage analysis available (disabled by user)")
+ else()
+ message(STATUS "Code coverage analysis enabled")
+ test_and_set_c_compiler_flag_global(-g)
+ test_and_set_c_compiler_flag_global(--coverage)
+ add_link_options(--coverage)
+ endif()
+else()
+ set(HAVE_GCOV FALSE CACHE INTERNAL "gcov coverage tool available")
+ message(STATUS "gcov not found - coverage analysis not available")
+endif()
+
+mark_as_advanced(GCOV_PATH)
diff --git a/cmake/dependencies/lcov.cmake b/cmake/dependencies/coverage/lcov.cmake
index db559332..65ed316e 100644
--- a/cmake/dependencies/lcov.cmake
+++ b/cmake/dependencies/coverage/lcov.cmake
@@ -1,17 +1,17 @@
find_program(LCOV_PATH lcov)
find_program(GENHTML_PATH genhtml)
-if (LCOV_PATH AND GENHTML_PATH)
- set(HAVE_LCOV TRUE CACHE INTERNAL "")
+if(LCOV_PATH AND GENHTML_PATH)
+ set(HAVE_LCOV TRUE CACHE INTERNAL "lcov HTML coverage reports available")
message(STATUS "lcov and genhtml found - HTML coverage reports available")
-else ()
- set(HAVE_LCOV FALSE CACHE INTERNAL "")
- if (NOT LCOV_PATH)
+else()
+ set(HAVE_LCOV FALSE CACHE INTERNAL "lcov HTML coverage reports available")
+ if(NOT LCOV_PATH)
message(STATUS "lcov not found - HTML coverage reports not available")
- endif ()
- if (NOT GENHTML_PATH)
+ endif()
+ if(NOT GENHTML_PATH)
message(STATUS "genhtml not found - HTML coverage reports not available")
- endif ()
-endif ()
+ endif()
+endif()
mark_as_advanced(LCOV_PATH GENHTML_PATH)
diff --git a/cmake/dependencies/crypt/libgcrypt.cmake b/cmake/dependencies/crypt/libgcrypt.cmake
new file mode 100644
index 00000000..4f8a4cfe
--- /dev/null
+++ b/cmake/dependencies/crypt/libgcrypt.cmake
@@ -0,0 +1,55 @@
+# Try pkg-config first, fall back to find_library
+if(PkgConfig_FOUND)
+ pkg_check_modules(LIBGCRYPT QUIET IMPORTED_TARGET libgcrypt>=1.7.0)
+ if(LIBGCRYPT_FOUND AND NOT TARGET Gcrypt::Gcrypt)
+ add_library(Gcrypt::Gcrypt ALIAS PkgConfig::LIBGCRYPT)
+ endif()
+endif()
+
+if(NOT LIBGCRYPT_FOUND)
+ find_library(LIBGCRYPT_LIBRARIES gcrypt QUIET)
+ if(LIBGCRYPT_LIBRARIES)
+ find_path(LIBGCRYPT_INCLUDE_DIR gcrypt.h
+ HINTS /usr/include /usr/local/include)
+ if(LIBGCRYPT_INCLUDE_DIR)
+ file(STRINGS ${LIBGCRYPT_INCLUDE_DIR}/gcrypt.h GCSTR
+ REGEX "^#define GCRYPT_VERSION ")
+ string(REGEX REPLACE "^#define GCRYPT_VERSION \"(.*)\".*$" "\\1"
+ LIBGCRYPT_VERSION "${GCSTR}")
+ if(NOT LIBGCRYPT_VERSION VERSION_LESS "1.7.0")
+ set(LIBGCRYPT_FOUND TRUE)
+ if(NOT TARGET Gcrypt::Gcrypt)
+ add_library(Gcrypt::Gcrypt UNKNOWN IMPORTED)
+ set_target_properties(Gcrypt::Gcrypt PROPERTIES
+ IMPORTED_LOCATION "${LIBGCRYPT_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${LIBGCRYPT_INCLUDE_DIR}")
+ endif()
+ endif()
+ endif()
+ endif()
+endif()
+
+if(LIBGCRYPT_FOUND)
+ set(DISABLE_LIBGCRYPT FALSE CACHE BOOL "Disable libgcrypt support")
+ if(NOT DISABLE_LIBGCRYPT)
+ if(LIBGCRYPT_VERSION)
+ message(STATUS "libgcrypt support enabled (version ${LIBGCRYPT_VERSION})")
+ else()
+ message(STATUS "libgcrypt support enabled")
+ endif()
+ set(HAVE_LIBGCRYPT TRUE CACHE INTERNAL "libgcrypt cryptography support available")
+ else()
+ message(STATUS "libgcrypt support disabled by user")
+ unset(HAVE_LIBGCRYPT CACHE)
+ endif()
+else()
+ message(STATUS "Install libgcrypt >= 1.7.0 to enable libgcrypt support")
+ unset(HAVE_LIBGCRYPT CACHE)
+endif()
+
+if(NOT HAVE_LIBGCRYPT)
+ set(LIBGCRYPT_LIBRARIES "")
+ set(LIBGCRYPT_INCLUDE_DIR "")
+endif()
+
+mark_as_advanced(LIBGCRYPT_LIBRARIES LIBGCRYPT_INCLUDE_DIR)
diff --git a/cmake/dependencies/openssl.cmake b/cmake/dependencies/crypt/openssl.cmake
index b02d64b4..ed07cc9d 100644
--- a/cmake/dependencies/openssl.cmake
+++ b/cmake/dependencies/crypt/openssl.cmake
@@ -1,18 +1,18 @@
find_package(OpenSSL QUIET)
-if (OPENSSL_FOUND)
+if(OPENSSL_FOUND)
set(HAVE_OPENSSL_RNG TRUE)
- if (OPENSSL_VERSION VERSION_LESS "3.0.0")
+ if(OPENSSL_VERSION VERSION_LESS "3.0.0")
message(STATUS "Install version >= 3.0.0 to enable OpenSSL support "
"(found version \"${OPENSSL_VERSION}\")")
- else ()
+ else()
set(DISABLE_OPENSSL FALSE CACHE BOOL "Disable OpenSSL support")
- if (NOT DISABLE_OPENSSL)
+ if(NOT DISABLE_OPENSSL)
message(STATUS "OpenSSL support enabled, found version ${OPENSSL_VERSION}")
- set(HAVE_OPENSSL TRUE CACHE INTERNAL "")
+ set(HAVE_OPENSSL TRUE CACHE INTERNAL "OpenSSL cryptography support available")
set(DISABLE_PQC FALSE CACHE BOOL "Disable post-quantum cryptography support")
- if (OPENSSL_VERSION VERSION_GREATER_EQUAL "3.4.0")
- if (NOT DISABLE_PQC)
- set(HAVE_OPENSSL_PQC TRUE CACHE INTERNAL "")
+ if(OPENSSL_VERSION VERSION_GREATER_EQUAL "3.4.0")
+ if(NOT DISABLE_PQC)
+ set(HAVE_OPENSSL_PQC TRUE CACHE INTERNAL "OpenSSL post-quantum cryptography available")
message(STATUS "OpenSSL PQC support enabled")
else()
message(STATUS "OpenSSL PQC support disabled by user")
@@ -25,18 +25,11 @@ if (OPENSSL_FOUND)
message(STATUS "OpenSSL support disabled")
unset(HAVE_OPENSSL CACHE)
endif()
- endif ()
+ endif()
else()
message(STATUS "Install OpenSSL version >= 3.0.0 to enable OpenSSL support")
unset(HAVE_OPENSSL_RNG)
unset(HAVE_OPENSSL CACHE)
- set(OPENSSL_INCLUDE_DIR "")
- set(OPENSSL_LIBRARIES "")
- set(OPENSSL_CRYPTO_LIBRARY "")
-endif ()
+endif()
-set(IRMD_SECMEM_MAX 1048576 CACHE STRING "IRMd secure heap size")
-set(PROC_SECMEM_MAX 1048576 CACHE STRING "Process secure heap size")
-set(SECMEM_GUARD 32 CACHE STRING "Secure heap min size")
-
-mark_as_advanced(OPENSSL_LIBRARIES OPENSSL_CRYPTO_LIBRARY)
+# Secure memory options are in cmake/config/global.cmake
diff --git a/cmake/dependencies/bpf.cmake b/cmake/dependencies/eth/bpf.cmake
index 8c04937f..c2f69e79 100644
--- a/cmake/dependencies/bpf.cmake
+++ b/cmake/dependencies/eth/bpf.cmake
@@ -1,20 +1,20 @@
# Berkeley Packet Filter support (BSD/macOS only)
-if (NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
+if(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
find_path(BPF_C_INCLUDE_DIR
net/bpf.h
HINTS /usr/include /usr/local/include)
mark_as_advanced(BPF_C_INCLUDE_DIR)
- if (BPF_C_INCLUDE_DIR)
+ if(BPF_C_INCLUDE_DIR)
set(DISABLE_BPF FALSE CACHE BOOL
"Disable Berkeley Packet Filter support for Ethernet IPCPs")
- if (NOT DISABLE_BPF)
+ if(NOT DISABLE_BPF)
message(STATUS "Berkeley Packet Filter support for Ethernet IPCPs enabled")
set(HAVE_BPF TRUE)
- else ()
+ else()
message(STATUS "Berkeley Packet Filter support for Ethernet IPCPs disabled by user")
unset(HAVE_BPF)
- endif ()
- endif ()
-endif ()
+ endif()
+ endif()
+endif()
diff --git a/cmake/dependencies/netmap.cmake b/cmake/dependencies/eth/netmap.cmake
index d8d3781b..94ecd634 100644
--- a/cmake/dependencies/netmap.cmake
+++ b/cmake/dependencies/eth/netmap.cmake
@@ -5,14 +5,14 @@ find_path(NETMAP_C_INCLUDE_DIR
mark_as_advanced(NETMAP_C_INCLUDE_DIR)
-if (NOT HAVE_RAW_SOCKETS AND NOT HAVE_BPF AND NETMAP_C_INCLUDE_DIR)
+if(NOT HAVE_RAW_SOCKETS AND NOT HAVE_BPF AND NETMAP_C_INCLUDE_DIR)
set(DISABLE_NETMAP FALSE CACHE BOOL
"Disable netmap support for ETH IPCPs")
- if (NOT DISABLE_NETMAP)
+ if(NOT DISABLE_NETMAP)
message(STATUS "Netmap support for Ethernet IPCPs enabled")
set(HAVE_NETMAP TRUE)
- else ()
+ else()
message(STATUS "Netmap support for Ethernet IPCPs disabled by user")
unset(HAVE_NETMAP)
- endif ()
-endif ()
+ endif()
+endif()
diff --git a/cmake/dependencies/rawsockets.cmake b/cmake/dependencies/eth/rawsockets.cmake
index 92f7b8b7..395d9efb 100644
--- a/cmake/dependencies/rawsockets.cmake
+++ b/cmake/dependencies/eth/rawsockets.cmake
@@ -1,12 +1,12 @@
# Raw sockets support (Linux only)
-if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
+if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(DISABLE_RAW_SOCKETS FALSE CACHE BOOL
"Disable raw socket support for Ethernet IPCPs")
- if (NOT DISABLE_RAW_SOCKETS)
+ if(NOT DISABLE_RAW_SOCKETS)
message(STATUS "Raw socket support for Ethernet IPCPs enabled")
set(HAVE_RAW_SOCKETS TRUE)
- else ()
+ else()
message(STATUS "Raw socket support for Ethernet IPCPs disabled by user")
unset(HAVE_RAW_SOCKETS)
- endif ()
-endif ()
+ endif()
+endif()
diff --git a/cmake/dependencies/explicit_bzero.cmake b/cmake/dependencies/explicit_bzero.cmake
deleted file mode 100644
index 54a11d21..00000000
--- a/cmake/dependencies/explicit_bzero.cmake
+++ /dev/null
@@ -1 +0,0 @@
-check_symbol_exists(explicit_bzero "string.h" HAVE_EXPLICIT_BZERO) \ No newline at end of file
diff --git a/cmake/dependencies/fuse.cmake b/cmake/dependencies/fuse.cmake
deleted file mode 100644
index 8ef60292..00000000
--- a/cmake/dependencies/fuse.cmake
+++ /dev/null
@@ -1,23 +0,0 @@
-find_library(FUSE_LIBRARIES fuse QUIET)
-if (FUSE_LIBRARIES)
- #FIXME: Check for version >= 2.6
- set(DISABLE_FUSE FALSE CACHE BOOL "Disable FUSE support")
- if (NOT DISABLE_FUSE)
- message(STATUS "FUSE support enabled")
- set(FUSE_PREFIX "/tmp/ouroboros" CACHE STRING
- "Mountpoint for RIB filesystem")
- set(HAVE_FUSE TRUE CACHE INTERNAL "")
- else ()
- message(STATUS "FUSE support disabled by user")
- unset(HAVE_FUSE CACHE)
- endif ()
-else ()
- message(STATUS "Install FUSE version > 2.6 to enable RIB access")
-endif ()
-
-if (NOT HAVE_FUSE)
- set(FUSE_LIBRARIES "")
- set(FUSE_INCLUDE_DIR "")
-endif ()
-
-mark_as_advanced(FUSE_LIBRARIES)
diff --git a/cmake/dependencies/gcov.cmake b/cmake/dependencies/gcov.cmake
deleted file mode 100644
index c4d1caf0..00000000
--- a/cmake/dependencies/gcov.cmake
+++ /dev/null
@@ -1,11 +0,0 @@
-find_program(GCOV_PATH gcov)
-
-if (GCOV_PATH)
- set(HAVE_GCOV TRUE CACHE INTERNAL "")
- message(STATUS "gcov found - coverage analysis available")
-else ()
- set(HAVE_GCOV FALSE CACHE INTERNAL "")
- message(STATUS "gcov not found - coverage analysis not available")
-endif ()
-
-mark_as_advanced(GCOV_PATH)
diff --git a/cmake/dependencies/irmd/libtoml.cmake b/cmake/dependencies/irmd/libtoml.cmake
new file mode 100644
index 00000000..dcbc17e4
--- /dev/null
+++ b/cmake/dependencies/irmd/libtoml.cmake
@@ -0,0 +1,29 @@
+find_library(LIBTOML_LIBRARY toml QUIET)
+if(LIBTOML_LIBRARY)
+ find_path(LIBTOML_INCLUDE_DIR toml.h)
+ set(DISABLE_CONFIGFILE FALSE CACHE BOOL
+ "Disable configuration file support")
+ if(NOT DISABLE_CONFIGFILE)
+ set(OUROBOROS_CONFIG_FILE irmd.conf CACHE STRING
+ "Name of the IRMd configuration file")
+ set(HAVE_TOML TRUE CACHE INTERNAL "TOML configuration file support available")
+ message(STATUS "Configuration file support enabled")
+ message(STATUS "Configuration directory: ${OUROBOROS_CONFIG_DIR}")
+ # Create imported target for consistency with other dependencies
+ if(NOT TARGET toml::toml)
+ add_library(toml::toml UNKNOWN IMPORTED)
+ set_target_properties(toml::toml PROPERTIES
+ IMPORTED_LOCATION "${LIBTOML_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${LIBTOML_INCLUDE_DIR}")
+ endif()
+ else()
+ message(STATUS "Configuration file support disabled by user")
+ unset(OUROBOROS_CONFIG_FILE CACHE)
+ unset(HAVE_TOML CACHE)
+ endif()
+ mark_as_advanced(LIBTOML_LIBRARY LIBTOML_INCLUDE_DIR)
+else()
+ message(STATUS "Install tomlc99 for config file support")
+ message(STATUS " https://github.com/cktan/tomlc99")
+ unset(HAVE_TOML CACHE)
+endif()
diff --git a/cmake/dependencies/libgcrypt.cmake b/cmake/dependencies/libgcrypt.cmake
deleted file mode 100644
index 90a25f36..00000000
--- a/cmake/dependencies/libgcrypt.cmake
+++ /dev/null
@@ -1,31 +0,0 @@
-find_library(LIBGCRYPT_LIBRARIES gcrypt QUIET)
-if (LIBGCRYPT_LIBRARIES)
- find_path(LIBGCRYPT_INCLUDE_DIR gcrypt.h
- HINTS /usr/include /usr/local/include)
- if (LIBGCRYPT_INCLUDE_DIR)
- file(STRINGS ${LIBGCRYPT_INCLUDE_DIR}/gcrypt.h GCSTR
- REGEX "^#define GCRYPT_VERSION ")
- string(REGEX REPLACE "^#define GCRYPT_VERSION \"(.*)\".*$" "\\1"
- GCVER "${GCSTR}")
- if (NOT GCVER VERSION_LESS "1.7.0")
- set(DISABLE_LIBGCRYPT FALSE CACHE BOOL "Disable libgcrypt support")
- if (NOT DISABLE_LIBGCRYPT)
- message(STATUS "libgcrypt support enabled")
- set(HAVE_LIBGCRYPT TRUE CACHE INTERNAL "")
- else ()
- message(STATUS "libgcrypt support disabled by user")
- unset(HAVE_LIBGCRYPT CACHE)
- endif()
- else ()
- message(STATUS "Install version >= \"1.7.0\" to enable libgcrypt support "
- "(found version \"${GCVER}\")")
- endif()
- endif ()
-endif ()
-
-if (NOT HAVE_LIBGCRYPT)
- set(LIBGCRYPT_LIBRARIES "")
- set(LIBGCRYPT_INCLUDE_DIR "")
-endif ()
-
-mark_as_advanced(LIBGCRYPT_LIBRARIES LIBGCRYPT_INCLUDE_DIR)
diff --git a/cmake/dependencies/libtoml.cmake b/cmake/dependencies/libtoml.cmake
deleted file mode 100644
index 3974a1dd..00000000
--- a/cmake/dependencies/libtoml.cmake
+++ /dev/null
@@ -1,5 +0,0 @@
-find_library(LIBTOML_LIBRARIES toml QUIET)
-if (LIBTOML_LIBRARIES)
- find_path(LIBTOML_INCLUDE toml.h)
- mark_as_advanced(LIBTOML_LIBRARIES LIBTOML_INCLUDE)
-endif ()
diff --git a/cmake/dependencies/sysrandom.cmake b/cmake/dependencies/sysrandom.cmake
deleted file mode 100644
index 972db801..00000000
--- a/cmake/dependencies/sysrandom.cmake
+++ /dev/null
@@ -1,21 +0,0 @@
-if (APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
- set(SYS_RND_HDR "")
-else ()
- find_path(SYS_RND_HDR sys/random.h PATH /usr/include/ /usr/local/include/)
- if (SYS_RND_HDR)
- message(STATUS "Found sys/random.h in ${SYS_RND_HDR}")
- set(HAVE_SYS_RANDOM TRUE)
- else ()
- set(SYS_RND_HDR "")
- unset(HAVE_SYS_RANDOM)
- endif ()
-endif()
-
-# Validate that at least one secure random generator is available
-if (NOT ((CMAKE_SYSTEM_NAME STREQUAL "FreeBSD") OR APPLE OR
- HAVE_SYS_RANDOM OR HAVE_OPENSSL_RNG OR HAVE_LIBGCRYPT))
- message(FATAL_ERROR "No secure random generator found, "
- "please install libgcrypt (> 1.7.0) or OpenSSL")
-endif ()
-
-mark_as_advanced(SYS_RND_HDR)
diff --git a/cmake/dependencies/system/explicit_bzero.cmake b/cmake/dependencies/system/explicit_bzero.cmake
new file mode 100644
index 00000000..89ab3abc
--- /dev/null
+++ b/cmake/dependencies/system/explicit_bzero.cmake
@@ -0,0 +1,4 @@
+# Check for explicit_bzero in string.h
+# glibc requires _DEFAULT_SOURCE to expose it; harmless on other platforms
+list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_DEFAULT_SOURCE)
+check_symbol_exists(explicit_bzero "string.h" HAVE_EXPLICIT_BZERO)
diff --git a/cmake/dependencies/system/fuse.cmake b/cmake/dependencies/system/fuse.cmake
new file mode 100644
index 00000000..7de12b31
--- /dev/null
+++ b/cmake/dependencies/system/fuse.cmake
@@ -0,0 +1,44 @@
+# Try pkg-config first, fall back to find_library
+if(PkgConfig_FOUND)
+ pkg_check_modules(FUSE QUIET IMPORTED_TARGET fuse>=2.6)
+ if(FUSE_FOUND AND NOT TARGET Fuse::Fuse)
+ add_library(Fuse::Fuse ALIAS PkgConfig::FUSE)
+ endif()
+endif()
+
+if(NOT FUSE_FOUND)
+ find_library(FUSE_LIBRARIES fuse QUIET)
+ if(FUSE_LIBRARIES)
+ set(FUSE_FOUND TRUE)
+ if(NOT TARGET Fuse::Fuse)
+ add_library(Fuse::Fuse UNKNOWN IMPORTED)
+ set_target_properties(Fuse::Fuse PROPERTIES
+ IMPORTED_LOCATION "${FUSE_LIBRARIES}")
+ endif()
+ endif()
+endif()
+
+if(FUSE_FOUND)
+ set(DISABLE_FUSE FALSE CACHE BOOL "Disable FUSE support")
+ if(NOT DISABLE_FUSE)
+ if(FUSE_VERSION)
+ message(STATUS "FUSE support enabled (version ${FUSE_VERSION})")
+ else()
+ message(STATUS "FUSE support enabled")
+ endif()
+ # FUSE_PREFIX is set in cmake/config/global.cmake
+ set(HAVE_FUSE TRUE CACHE INTERNAL "FUSE filesystem support available")
+ else()
+ message(STATUS "FUSE support disabled by user")
+ unset(HAVE_FUSE CACHE)
+ endif()
+else()
+ message(STATUS "Install FUSE version >= 2.6 to enable RIB access")
+ unset(HAVE_FUSE CACHE)
+endif()
+
+if(NOT HAVE_FUSE)
+ set(FUSE_LIBRARIES "")
+endif()
+
+mark_as_advanced(FUSE_LIBRARIES)
diff --git a/cmake/dependencies/system/libraries.cmake b/cmake/dependencies/system/libraries.cmake
new file mode 100644
index 00000000..55c22d6a
--- /dev/null
+++ b/cmake/dependencies/system/libraries.cmake
@@ -0,0 +1,17 @@
+if(NOT APPLE)
+ find_library(LIBRT_LIBRARIES rt)
+ mark_as_advanced(LIBRT_LIBRARIES)
+ if(NOT LIBRT_LIBRARIES)
+ message(FATAL_ERROR "Could not find librt")
+ endif()
+else()
+ set(LIBRT_LIBRARIES "")
+endif()
+
+find_package(Threads REQUIRED)
+
+find_library(LIBM_LIBRARIES m)
+mark_as_advanced(LIBM_LIBRARIES)
+if(NOT LIBM_LIBRARIES)
+ message(FATAL_ERROR "Could not find libm")
+endif()
diff --git a/cmake/dependencies/protobufc.cmake b/cmake/dependencies/system/protobufc.cmake
index f1fab59d..b7e0062a 100644
--- a/cmake/dependencies/protobufc.cmake
+++ b/cmake/dependencies/system/protobufc.cmake
@@ -1,11 +1,13 @@
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/utils")
find_package(ProtobufC QUIET)
-if (NOT (PROTOBUF_C_INCLUDE_DIRS AND PROTOBUF_C_LIBRARY
+if(NOT (PROTOBUF_C_INCLUDE_DIRS AND PROTOBUF_C_LIBRARY
AND PROTOBUF_PROTOC_C_EXECUTABLE))
message(FATAL_ERROR "Protobuf C compiler required but not found. "
"Please install Google Protocol Buffers.")
-else ()
+else()
message(STATUS "Found protobuf C compiler in ${PROTOBUF_PROTOC_C_EXECUTABLE}")
-endif ()
-include_directories(${PROTOBUF_C_INCLUDE_DIRS})
+endif()
+
+# Note: Include dirs are added per-target via target_include_directories
+# using ${PROTOBUF_C_INCLUDE_DIRS}
diff --git a/cmake/dependencies/robustmutex.cmake b/cmake/dependencies/system/robustmutex.cmake
index 94aec8f0..89b7325b 100644
--- a/cmake/dependencies/robustmutex.cmake
+++ b/cmake/dependencies/system/robustmutex.cmake
@@ -3,16 +3,16 @@ list(APPEND CMAKE_REQUIRED_DEFINITIONS -D__XSI_VISIBLE=500)
list(APPEND CMAKE_REQUIRED_LIBRARIES pthread)
check_symbol_exists(pthread_mutexattr_setrobust pthread.h HAVE_ROBUST_MUTEX)
-if (HAVE_ROBUST_MUTEX)
+if(HAVE_ROBUST_MUTEX)
set(DISABLE_ROBUST_MUTEXES FALSE CACHE BOOL "Disable robust mutex support")
- if (NOT DISABLE_ROBUST_MUTEXES)
+ if(NOT DISABLE_ROBUST_MUTEXES)
message(STATUS "Robust mutex support enabled")
set(HAVE_ROBUST_MUTEX TRUE)
- else ()
+ else()
message(STATUS "Robust mutex support disabled by user")
unset(HAVE_ROBUST_MUTEX)
- endif ()
+ endif()
else()
message(STATUS "Robust mutex support not available")
unset(HAVE_ROBUST_MUTEX)
-endif ()
+endif()
diff --git a/cmake/dependencies/system/sysrandom.cmake b/cmake/dependencies/system/sysrandom.cmake
new file mode 100644
index 00000000..dc8443a1
--- /dev/null
+++ b/cmake/dependencies/system/sysrandom.cmake
@@ -0,0 +1,14 @@
+if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
+ set(SYS_RND_HDR "")
+else()
+ find_path(SYS_RND_HDR sys/random.h PATH /usr/include/ /usr/local/include/)
+ if(SYS_RND_HDR)
+ message(STATUS "Found sys/random.h in ${SYS_RND_HDR}")
+ set(HAVE_SYS_RANDOM TRUE)
+ else()
+ set(SYS_RND_HDR "")
+ unset(HAVE_SYS_RANDOM)
+ endif()
+endif()
+
+mark_as_advanced(SYS_RND_HDR)
diff --git a/cmake/dependencies/systemlibraries.cmake b/cmake/dependencies/systemlibraries.cmake
deleted file mode 100644
index e00266d6..00000000
--- a/cmake/dependencies/systemlibraries.cmake
+++ /dev/null
@@ -1,20 +0,0 @@
-if (NOT APPLE)
- find_library(LIBRT_LIBRARIES rt)
- if (NOT LIBRT_LIBRARIES)
- message(FATAL_ERROR "Could not find librt")
- endif ()
-else ()
- set(LIBRT_LIBRARIES "")
-endif ()
-
-find_library(LIBPTHREAD_LIBRARIES pthread)
-if (NOT LIBPTHREAD_LIBRARIES)
- message(FATAL_ERROR "Could not find libpthread")
-endif ()
-
-find_library(LIBM_LIBRARIES m)
-if (NOT LIBM_LIBRARIES)
- message(FATAL_ERROR "Could not find libm")
-endif ()
-
-mark_as_advanced(LIBRT_LIBRARIES LIBPTHREAD_LIBRARIES LIBM_LIBRARIES)
diff --git a/cmake/dependencies/udp/ddns.cmake b/cmake/dependencies/udp/ddns.cmake
new file mode 100644
index 00000000..e8208e47
--- /dev/null
+++ b/cmake/dependencies/udp/ddns.cmake
@@ -0,0 +1,31 @@
+# DDNS (Dynamic DNS) support detection
+# Requires nsupdate and nslookup tools
+
+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 "Dynamic DNS support available")
+ 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()
diff --git a/cmake/doc.cmake b/cmake/doc.cmake
index 16991f82..f75cde5b 100644
--- a/cmake/doc.cmake
+++ b/cmake/doc.cmake
@@ -28,20 +28,12 @@ set(MAN_NAMES
irm.8
)
-macro(INSTALL_MAN __mans)
- foreach (_man ${ARGV})
- string(REGEX REPLACE "^.+[.]([1-9]).gz" "\\1" _mansect ${_man})
- install(FILES ${_man} DESTINATION "${CMAKE_INSTALL_MANDIR}/man${_mansect}")
- endforeach (_man)
-endmacro(INSTALL_MAN __mans)
-
find_program(GZIP_EXECUTABLE
NAMES gzip
DOC "Will gzip the man pages")
-
mark_as_advanced(GZIP_EXECUTABLE)
-if (GZIP_EXECUTABLE)
+if(GZIP_EXECUTABLE)
# Create the doc output directory
file(MAKE_DIRECTORY ${DOC_BINARY_DIR})
@@ -59,6 +51,4 @@ if (GZIP_EXECUTABLE)
endforeach ()
add_custom_target(man ALL DEPENDS ${MAN_FILES})
-
- INSTALL_MAN(${MAN_FILES})
-endif ()
+endif()
diff --git a/cmake/include.cmake b/cmake/include.cmake
index c14d205d..ace51d0f 100644
--- a/cmake/include.cmake
+++ b/cmake/include.cmake
@@ -1,7 +1,6 @@
set(HEADERS_SOURCE_DIR "${CMAKE_SOURCE_DIR}/include/ouroboros")
-set(SOCK_BUF_SIZE 10240 CACHE STRING
- "Size of the buffer used by the UNIX sockets for local IPC")
+# SOCK_BUF_SIZE is in cmake/config/global.cmake
configure_file("${CMAKE_SOURCE_DIR}/include/ouroboros/version.h.in"
"${CMAKE_BINARY_DIR}/include/ouroboros/version.h" @ONLY)
@@ -22,7 +21,4 @@ set(PUBLIC_HEADER_FILES
${HEADERS_SOURCE_DIR}/proto.h
${HEADERS_SOURCE_DIR}/qos.h
${CMAKE_BINARY_DIR}/include/ouroboros/version.h
- )
-
-install(FILES ${PUBLIC_HEADER_FILES}
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ouroboros)
+)
diff --git a/cmake/install.cmake b/cmake/install.cmake
index 21a8cd52..79714df2 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -1,12 +1,48 @@
# Installation configuration
-# Install pkg-config files
+include(CMakePackageConfigHelpers)
+
+# Public headers
+install(FILES ${PUBLIC_HEADER_FILES}
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ouroboros)
+
+# Man pages
+if(GZIP_EXECUTABLE)
+ foreach(_man ${MAN_FILES})
+ string(REGEX REPLACE "^.+[.]([1-9]).gz" "\\1" _mansect ${_man})
+ install(FILES ${_man} DESTINATION "${CMAKE_INSTALL_MANDIR}/man${_mansect}")
+ endforeach()
+endif()
+
+# pkg-config files
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-dev.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-irm.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+set(OUROBOROS_CMAKE_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/Ouroboros")
+
+install(EXPORT OuroborosTargets
+ FILE OuroborosTargets.cmake
+ NAMESPACE Ouroboros::
+ DESTINATION ${OUROBOROS_CMAKE_DIR})
+
+configure_package_config_file(
+ "${CMAKE_SOURCE_DIR}/cmake/OuroborosConfig.cmake.in"
+ "${CMAKE_BINARY_DIR}/OuroborosConfig.cmake"
+ INSTALL_DESTINATION ${OUROBOROS_CMAKE_DIR})
+
+write_basic_package_version_file(
+ "${CMAKE_BINARY_DIR}/OuroborosConfigVersion.cmake"
+ VERSION ${PACKAGE_VERSION}
+ COMPATIBILITY SameMajorVersion)
+
+install(FILES
+ "${CMAKE_BINARY_DIR}/OuroborosConfig.cmake"
+ "${CMAKE_BINARY_DIR}/OuroborosConfigVersion.cmake"
+ DESTINATION ${OUROBOROS_CMAKE_DIR})
+
# Systemd service file installation
set(SYSTEMD_INSTALL_FILES "DETECT" CACHE STRING
"Install systemd .service files (NO (never), DETECT (use pkg-config - default),\
@@ -15,50 +51,51 @@ set(SYSTEMD_UNITDIR_OVERRIDE "" CACHE PATH
"Path to install systemd files. When SYSTEMD_INSTALL_FILES == DETECT, this\
can be empty to automatically determine the path. Cannot be empty when FORCE.")
-if (SYSTEMD_INSTALL_FILES STREQUAL "DETECT" OR SYSTEMD_INSTALL_FILES STREQUAL "FORCE")
- if (SYSTEMD_INSTALL_FILES STREQUAL "DETECT")
- pkg_check_modules(SYSTEMD "systemd")
- if (SYSTEMD_FOUND)
- if ("${SYSTEMD_UNITDIR_OVERRIDE}" STREQUAL "")
+if(SYSTEMD_INSTALL_FILES STREQUAL "DETECT" OR SYSTEMD_INSTALL_FILES STREQUAL "FORCE")
+ if(SYSTEMD_INSTALL_FILES STREQUAL "DETECT")
+ if(PkgConfig_FOUND)
+ pkg_check_modules(SYSTEMD "systemd")
+ endif()
+ if(SYSTEMD_FOUND)
+ if(SYSTEMD_UNITDIR_OVERRIDE STREQUAL "")
execute_process(COMMAND ${PKG_CONFIG_EXECUTABLE}
--variable=systemdsystemunitdir systemd
OUTPUT_VARIABLE SYSTEMD_UNITDIR_INTERNAL)
string(REGEX REPLACE "[ \t\n]+" "" SYSTEMD_UNITDIR_INTERNAL
"${SYSTEMD_UNITDIR_INTERNAL}"
)
- else ()
+ else()
set(SYSTEMD_UNITDIR_INTERNAL "${SYSTEMD_UNITDIR_OVERRIDE}")
- endif ()
- else ()
+ endif()
+ else()
set(SYSTEMD_UNITDIR_INTERNAL "")
- endif ()
- elseif (SYSTEMD_INSTALL_FILES STREQUAL "FORCE")
- if ("${SYSTEMD_UNITDIR_OVERRIDE}" STREQUAL "")
+ endif()
+ elseif(SYSTEMD_INSTALL_FILES STREQUAL "FORCE")
+ if(SYSTEMD_UNITDIR_OVERRIDE STREQUAL "")
message(FATAL_ERROR "Systemd installation required by user, but no path\
provided with SYSTEMD_UNITDIR_OVERRIDE.")
- else ()
+ else()
set(SYSTEMD_UNITDIR_INTERNAL "${SYSTEMD_UNITDIR_OVERRIDE}")
- endif ()
+ endif()
endif()
- if (NOT ${SYSTEMD_UNITDIR_INTERNAL} STREQUAL "")
+ if(NOT SYSTEMD_UNITDIR_INTERNAL STREQUAL "")
message(STATUS "Systemd service installation enabled to: ${SYSTEMD_UNITDIR_INTERNAL}")
- if (LIBTOML_LIBRARIES AND NOT DISABLE_CONFIGFILE)
+ if(LIBTOML_LIBRARIES AND NOT DISABLE_CONFIGFILE)
set (CONFIGURE_STRING "--config ${OUROBOROS_CONFIG_DIR}/${OUROBOROS_CONFIG_FILE}")
- else ()
+ else()
set (CONFIGURE_STRING "")
- endif ()
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ouroboros.service.in"
- "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.service" @ONLY)
- install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros.service"
+ endif()
+ configure_file("${CMAKE_SOURCE_DIR}/ouroboros.service.in"
+ "${CMAKE_BINARY_DIR}/ouroboros.service" @ONLY)
+ install(FILES "${CMAKE_BINARY_DIR}/ouroboros.service"
DESTINATION "${SYSTEMD_UNITDIR_INTERNAL}")
- endif ()
-else ()
+ endif()
+else()
message(STATUS "Systemd service installation disabled by user")
endif()
-# Uninstall target
configure_file("${CMAKE_SOURCE_DIR}/cmake/utils/CMakeUninstall.cmake.in"
- "${CMAKE_BINARY_DIR}/cmake/cmakeuninstall.cmake" IMMEDIATE @ONLY)
+ "${CMAKE_BINARY_DIR}/cmake/cmakeuninstall.cmake" @ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/cmake/cmakeuninstall.cmake)
diff --git a/cmake/ipcp.cmake b/cmake/ipcp.cmake
deleted file mode 100644
index 6839fcc2..00000000
--- a/cmake/ipcp.cmake
+++ /dev/null
@@ -1,10 +0,0 @@
-include(ipcp/ipcp)
-include(ipcp/eth)
-include(ipcp/udp)
-include(ipcp/local)
-include(ipcp/broadcast)
-include(ipcp/unicast)
-
-configure_file("${IPCP_SOURCE_DIR}/config.h.in"
- "${IPCP_BINARY_DIR}/config.h" @ONLY)
-
diff --git a/cmake/ipcp/broadcast.cmake b/cmake/ipcp/broadcast.cmake
deleted file mode 100644
index 4f43d001..00000000
--- a/cmake/ipcp/broadcast.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-set(BROADCAST_SOURCE_DIR "${IPCP_SOURCE_DIR}/broadcast")
-
-set(IPCP_BROADCAST_TARGET ipcpd-broadcast CACHE INTERNAL "")
-
-set(IPCP_BROADCAST_MPL 100 CACHE STRING
- "Default maximum packet lifetime for the Broadcast IPCP, in ms")
-
-set(BROADCAST_SOURCES
- "${BROADCAST_SOURCE_DIR}/connmgr.c"
- "${BROADCAST_SOURCE_DIR}/dt.c"
- "${BROADCAST_SOURCE_DIR}/main.c"
-)
-
-add_executable(${IPCP_BROADCAST_TARGET}
- ${BROADCAST_SOURCES}
- ${IPCP_SOURCES}
- ${COMMON_SOURCES}
-)
-
-target_include_directories(${IPCP_BROADCAST_TARGET} PRIVATE ${IPCP_INCLUDE_DIRS})
-target_link_libraries(${IPCP_BROADCAST_TARGET} PUBLIC ouroboros-dev)
-
-include(utils/AddCompileFlags)
-if (CMAKE_BUILD_TYPE MATCHES "Debug*")
- add_compile_flags(${IPCP_BROADCAST_TARGET} -DCONFIG_OUROBOROS_DEBUG)
-endif ()
-
-install(TARGETS ${IPCP_BROADCAST_TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
diff --git a/cmake/ipcp/eth.cmake b/cmake/ipcp/eth.cmake
deleted file mode 100644
index 0960c8a5..00000000
--- a/cmake/ipcp/eth.cmake
+++ /dev/null
@@ -1,48 +0,0 @@
-set(ETH_SOURCE_DIR "${IPCP_SOURCE_DIR}/eth")
-
-set(IPCP_ETH_LLC_TARGET ipcpd-eth-llc CACHE INTERNAL "")
-set(IPCP_ETH_DIX_TARGET ipcpd-eth-dix CACHE INTERNAL "")
-
-set(IPCP_ETH_RD_THR 1 CACHE STRING
- "Number of reader threads in Ethernet IPCP")
-set(IPCP_ETH_WR_THR 1 CACHE STRING
- "Number of writer threads in Ethernet IPCP")
-set(IPCP_ETH_QDISC_BYPASS false CACHE BOOL
- "Bypass the Qdisc in the kernel when using raw sockets")
-set(IPCP_ETH_LO_MTU 9000 CACHE STRING
- "Restrict Ethernet MTU over loopback interfaces")
-set(IPCP_ETH_MGMT_FRAME_SIZE 9000 CACHE STRING
- "Management frame buffer size for Ethernet IPCPs")
-set(IPCP_ETH_MPL 100 CACHE STRING
- "Default maximum packet lifetime for the Ethernet IPCPs, in ms")
-
-if (HAVE_RAW_SOCKETS OR HAVE_BPF OR HAVE_NETMAP)
- set(HAVE_ETH TRUE)
-else ()
- unset(HAVE_ETH)
-endif ()
-
-if (HAVE_ETH)
- add_executable(${IPCP_ETH_LLC_TARGET} "${ETH_SOURCE_DIR}/llc.c" ${IPCP_SOURCES})
- add_executable(${IPCP_ETH_DIX_TARGET} "${ETH_SOURCE_DIR}/dix.c" ${IPCP_SOURCES})
-
- foreach(target ${IPCP_ETH_LLC_TARGET} ${IPCP_ETH_DIX_TARGET})
- target_include_directories(${target} PRIVATE ${IPCP_INCLUDE_DIRS})
- if (HAVE_BPF AND NOT APPLE)
- target_include_directories(${target} PRIVATE ${BPF_C_INCLUDE_DIR})
- endif ()
- if (HAVE_NETMAP AND NOT APPLE)
- set_target_properties(${target} PROPERTIES COMPILE_FLAGS "${CMAKE_C_FLAGS} -std=c99")
- target_include_directories(${target} PRIVATE ${NETMAP_C_INCLUDE_DIR})
- endif ()
- target_link_libraries(${target} PUBLIC ouroboros-dev)
- endforeach()
-
- include(utils/AddCompileFlags)
- if (CMAKE_BUILD_TYPE MATCHES "Debug*")
- add_compile_flags(${IPCP_ETH_LLC_TARGET} -DCONFIG_OUROBOROS_DEBUG)
- add_compile_flags(${IPCP_ETH_DIX_TARGET} -DCONFIG_OUROBOROS_DEBUG)
- endif ()
-
- install(TARGETS ${IPCP_ETH_LLC_TARGET} ${IPCP_ETH_DIX_TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
-endif ()
diff --git a/cmake/ipcp/ipcp.cmake b/cmake/ipcp/ipcp.cmake
deleted file mode 100644
index 006e76b0..00000000
--- a/cmake/ipcp/ipcp.cmake
+++ /dev/null
@@ -1,60 +0,0 @@
-set(IPCP_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/ipcpd")
-set(IPCP_BINARY_DIR "${CMAKE_BINARY_DIR}/src/ipcpd")
-
-set(CONNMGR_RCV_TIMEOUT 1000 CACHE STRING
- "Timeout for the connection manager to wait for OCEP info (ms).")
-set(IPCP_DEBUG_LOCAL FALSE CACHE BOOL
- "Use PID as address for local debugging")
-set(IPCP_QOS_CUBE_BE_PRIO 50 CACHE STRING
- "Priority for best effort QoS cube (0-99)")
-set(IPCP_QOS_CUBE_VIDEO_PRIO 90 CACHE STRING
- "Priority for video QoS cube (0-99)")
-set(IPCP_QOS_CUBE_VOICE_PRIO 99 CACHE STRING
- "Priority for voice QoS cube (0-99)")
-set(IPCP_MIN_THREADS 4 CACHE STRING
- "Minimum number of worker threads in the IPCP")
-set(IPCP_ADD_THREADS 4 CACHE STRING
- "Number of extra threads to start when an IPCP faces thread starvation")
-set(IPCP_SCHED_THR_MUL 2 CACHE STRING
- "Number of scheduler threads per QoS cube")
-set(DISABLE_CORE_LOCK TRUE CACHE BOOL
- "Disable locking performance threads to a core")
-set(BUILD_CONTAINER FALSE CACHE BOOL
- "Disable thread priority setting for container compatibility")
-
-if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
- set(IPCP_LINUX_TIMERSLACK_NS 100 CACHE STRING
- "Slack value for high resolution timers on Linux systems.")
-endif ()
-
-if ((IPCP_QOS_CUBE_BE_PRIO LESS 0) OR (IPCP_QOS_CUBE_BE_PRIO GREATER 99))
- message(FATAL_ERROR "Invalid priority for best effort QoS cube")
-endif ()
-
-if ((IPCP_QOS_CUBE_VIDEO_PRIO LESS 0) OR (IPCP_QOS_CUBE_VIDEO_PRIO GREATER 99))
- message(FATAL_ERROR "Invalid priority for video QoS cube")
-endif ()
-
-if ((IPCP_QOS_CUBE_VOICE_PRIO LESS 0) OR (IPCP_QOS_CUBE_VOICE_PRIO GREATER 99))
- message(FATAL_ERROR "Invalid priority for voice QoS cube")
-endif ()
-
-if ((DHT_ENROLL_SLACK LESS 0) OR (DHT_ENROLL_SLACK GREATER 999))
- message(FATAL_ERROR "Invalid DHT slack value")
-endif ()
-
-set(IPCP_SOURCES
- "${IPCP_SOURCE_DIR}/ipcp.c"
- "${IPCP_SOURCE_DIR}/shim-data.c"
-)
-
-set(COMMON_SOURCES
- "${IPCP_SOURCE_DIR}/common/enroll.c"
-)
-
-set(IPCP_INCLUDE_DIRS
- ${IPCP_SOURCE_DIR}
- ${IPCP_BINARY_DIR}
- ${CMAKE_SOURCE_DIR}/include
- ${CMAKE_BINARY_DIR}/include
-)
diff --git a/cmake/ipcp/local.cmake b/cmake/ipcp/local.cmake
deleted file mode 100644
index 7b604ba1..00000000
--- a/cmake/ipcp/local.cmake
+++ /dev/null
@@ -1,28 +0,0 @@
-set(LOCAL_SOURCE_DIR "${IPCP_SOURCE_DIR}/local")
-
-set(IPCP_LOCAL_TARGET ipcpd-local CACHE INTERNAL "")
-
-set(IPCP_LOCAL_MPL 100 CACHE STRING
- "Default maximum packet lifetime for the Local IPCP, in ms")
-
-set(IPCP_LOCAL_POLLING FALSE CACHE BOOL
- "Enable active polling in the Local IPCP for low-latency mode")
-
-add_executable(${IPCP_LOCAL_TARGET} "${LOCAL_SOURCE_DIR}/main.c" ${IPCP_SOURCES})
-target_include_directories(${IPCP_LOCAL_TARGET} PRIVATE ${IPCP_INCLUDE_DIRS})
-target_link_libraries(${IPCP_LOCAL_TARGET} PUBLIC ouroboros-dev)
-
-include(utils/AddCompileFlags)
-if (CMAKE_BUILD_TYPE MATCHES "Debug*")
- add_compile_flags(${IPCP_LOCAL_TARGET} -DCONFIG_OUROBOROS_DEBUG)
-endif ()
-
-if (IPCP_LOCAL_POLLING)
- add_compile_flags(${IPCP_LOCAL_TARGET} -DCONFIG_IPCP_LOCAL_POLLING)
-endif ()
-
-if (IPCP_LOCAL_POLLING)
- add_compile_flags(${IPCP_LOCAL_TARGET} -DCONFIG_IPCP_LOCAL_POLLING)
-endif ()
-
-install(TARGETS ${IPCP_LOCAL_TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
diff --git a/cmake/ipcp/udp.cmake b/cmake/ipcp/udp.cmake
deleted file mode 100644
index 360330c5..00000000
--- a/cmake/ipcp/udp.cmake
+++ /dev/null
@@ -1,57 +0,0 @@
-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()
-
-include(utils/AddCompileFlags)
-if (CMAKE_BUILD_TYPE MATCHES "Debug*")
- add_compile_flags(${IPCP_UDP4_TARGET} -DCONFIG_OUROBOROS_DEBUG)
- add_compile_flags(${IPCP_UDP6_TARGET} -DCONFIG_OUROBOROS_DEBUG)
-endif ()
-
-install(TARGETS ${IPCP_UDP4_TARGET} ${IPCP_UDP6_TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
diff --git a/cmake/ipcp/unicast.cmake b/cmake/ipcp/unicast.cmake
deleted file mode 100644
index de237500..00000000
--- a/cmake/ipcp/unicast.cmake
+++ /dev/null
@@ -1,56 +0,0 @@
-set(UNICAST_SOURCE_DIR "${IPCP_SOURCE_DIR}/unicast")
-set(UNICAST_BINARY_DIR "${IPCP_BINARY_DIR}/unicast")
-
-set(IPCP_UNICAST_TARGET ipcpd-unicast CACHE INTERNAL "")
-
-set(IPCP_UNICAST_MPL 100 CACHE STRING
- "Default maximum packet lifetime for the Unicast IPCP, in ms")
-set(PFT_SIZE 256 CACHE STRING
- "Prefix forwarding table size for the Unicast IPCP")
-set(DEBUG_PROTO_DHT FALSE CACHE BOOL
- "Add DHT protocol debug logging")
-set(DEBUG_PROTO_LS FALSE CACHE BOOL
- "Add link state protocol debug logging")
-
-# Generate DHT protobuf files
-protobuf_generate_c(DHT_PROTO_SRCS DHT_PROTO_HDRS "${UNICAST_SOURCE_DIR}/dir/dht.proto")
-
-set (UNICAST_SOURCES
- "${UNICAST_SOURCE_DIR}/addr-auth.c"
- "${UNICAST_SOURCE_DIR}/ca.c"
- "${UNICAST_SOURCE_DIR}/connmgr.c"
- "${UNICAST_SOURCE_DIR}/dir.c"
- "${UNICAST_SOURCE_DIR}/dt.c"
- "${UNICAST_SOURCE_DIR}/fa.c"
- "${UNICAST_SOURCE_DIR}/main.c"
- "${UNICAST_SOURCE_DIR}/pff.c"
- "${UNICAST_SOURCE_DIR}/routing.c"
- "${UNICAST_SOURCE_DIR}/psched.c"
- "${UNICAST_SOURCE_DIR}/addr-auth/flat.c"
- "${UNICAST_SOURCE_DIR}/ca/mb-ecn.c"
- "${UNICAST_SOURCE_DIR}/ca/nop.c"
- "${UNICAST_SOURCE_DIR}/dir/dht.c"
- "${UNICAST_SOURCE_DIR}/pff/simple.c"
- "${UNICAST_SOURCE_DIR}/pff/alternate.c"
- "${UNICAST_SOURCE_DIR}/pff/multipath.c"
- "${UNICAST_SOURCE_DIR}/pff/pft.c"
- "${UNICAST_SOURCE_DIR}/routing/link-state.c"
- "${UNICAST_SOURCE_DIR}/routing/graph.c"
-)
-
-add_executable(${IPCP_UNICAST_TARGET}
- ${UNICAST_SOURCES}
- ${IPCP_SOURCES}
- ${COMMON_SOURCES}
- ${DHT_PROTO_SRCS}
-)
-target_include_directories(${IPCP_UNICAST_TARGET} PRIVATE ${IPCP_INCLUDE_DIRS})
-target_include_directories(${IPCP_UNICAST_TARGET} PRIVATE "${UNICAST_SOURCE_DIR}")
-target_link_libraries(${IPCP_UNICAST_TARGET} PUBLIC ouroboros-dev)
-
-include(utils/AddCompileFlags)
-if (CMAKE_BUILD_TYPE MATCHES "Debug*")
- add_compile_flags(${IPCP_UNICAST_TARGET} -DCONFIG_OUROBOROS_DEBUG)
-endif ()
-
-install(TARGETS ${IPCP_UNICAST_TARGET} RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
diff --git a/cmake/irmd.cmake b/cmake/irmd.cmake
deleted file mode 100644
index 1d6341d3..00000000
--- a/cmake/irmd.cmake
+++ /dev/null
@@ -1,126 +0,0 @@
-set(IRMD_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/irmd")
-set(IRMD_BINARY_DIR "${CMAKE_BINARY_DIR}/src/irmd")
-
-set(OUROBOROS_CONFIG_DIR /etc/ouroboros CACHE STRING
- "Configuration directory (should be absolute)")
-
-# Configuration file support
-set(OUROBOROS_SECURITY_DIR "${OUROBOROS_CONFIG_DIR}/security" CACHE STRING
- "Security directory holding authentication information")
-set(OUROBOROS_CA_CRT_DIR "${OUROBOROS_SECURITY_DIR}/cacert" CACHE STRING
- "Directory holding trusted CA certificates")
-set(OUROBOROS_SRV_CRT_DIR "${OUROBOROS_SECURITY_DIR}/server" CACHE STRING
- "Directory holding server certificates")
-set(OUROBOROS_CLI_CRT_DIR "${OUROBOROS_SECURITY_DIR}/client" CACHE STRING
- "Directory holding client certificates")
-set(OUROBOROS_UNTRUSTED_DIR "${OUROBOROS_SECURITY_DIR}/untrusted" CACHE STRING
- "Directory holding untrusted intermediate certificates")
-
-# IRMd timeouts and parameters
-set(IRMD_REQ_ARR_TIMEOUT 1000 CACHE STRING
- "Timeout for an application to respond to a new flow (ms)")
-set(BOOTSTRAP_TIMEOUT 5000 CACHE STRING
- "Timeout for an IPCP to bootstrap (ms)")
-set(ENROLL_TIMEOUT 20000 CACHE STRING
- "Timeout for an IPCP to enroll (ms)")
-set(REG_TIMEOUT 20000 CACHE STRING
- "Timeout for registering a name (ms)")
-set(QUERY_TIMEOUT 200 CACHE STRING
- "Timeout to query a name with an IPCP (ms)")
-set(CONNECT_TIMEOUT 20000 CACHE STRING
- "Timeout to connect an IPCP to another IPCP (ms)")
-set(FLOW_ALLOC_TIMEOUT 20000 CACHE STRING
- "Timeout for a flow allocation response (ms)")
-set(OAP_REPLAY_TIMER 20 CACHE STRING
- "OAP replay protection window (s)")
-set(IRMD_MIN_THREADS 8 CACHE STRING
- "Minimum number of worker threads in the IRMd")
-set(IRMD_ADD_THREADS 8 CACHE STRING
- "Number of extra threads to start when the IRMD faces thread starvation")
-set(IRMD_PKILL_TIMEOUT 30 CACHE STRING
- "Number of seconds to wait before sending SIGKILL to subprocesses on exit")
-set(IRMD_KILL_ALL_PROCESSES TRUE CACHE BOOL
- "Kill all processes on exit")
-set(DEBUG_PROTO_OAP FALSE CACHE BOOL
- "Add Flow allocation protocol message output to IRMd debug logging")
-
-# Configuration file support (libtoml)
-if (LIBTOML_LIBRARIES)
- set(DISABLE_CONFIGFILE FALSE CACHE BOOL
- "Disable configuration file support")
- if (NOT DISABLE_CONFIGFILE)
- set(OUROBOROS_CONFIG_FILE irmd.conf CACHE STRING
- "Name of the IRMd configuration file")
- set(HAVE_TOML TRUE)
- message(STATUS "Configuration file support enabled")
- message(STATUS "Configuration directory: ${OUROBOROS_CONFIG_DIR}")
- set(INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}")
- configure_file("${CMAKE_SOURCE_DIR}/irmd.conf.in"
- "${CMAKE_BINARY_DIR}/${OUROBOROS_CONFIG_FILE}.example" @ONLY)
- configure_file("${CMAKE_SOURCE_DIR}/enc.conf.in"
- "${CMAKE_BINARY_DIR}/enc.conf.example" @ONLY)
- install(FILES "${CMAKE_BINARY_DIR}/${OUROBOROS_CONFIG_FILE}.example"
- DESTINATION "${OUROBOROS_CONFIG_DIR}")
- install(FILES "${CMAKE_BINARY_DIR}/enc.conf.example"
- DESTINATION "${OUROBOROS_CONFIG_DIR}")
- install(CODE "
- if (NOT EXISTS \"${OUROBOROS_CONFIG_DIR}/${OUROBOROS_CONFIG_FILE}\")
- file(WRITE \"${OUROBOROS_CONFIG_DIR}/${OUROBOROS_CONFIG_FILE}\" \"\")
- endif()
- ")
- unset(INSTALL_DIR)
- else ()
- message(STATUS "Configuration file support disabled by user")
- unset(OUROBOROS_CONFIG_FILE CACHE)
- set(HAVE_TOML FALSE)
- endif ()
-else ()
- message(STATUS "Install tomlc99 for config file support")
- message(STATUS " https://github.com/cktan/tomlc99")
- unset(HAVE_TOML)
-endif ()
-
-configure_file("${IRMD_SOURCE_DIR}/config.h.in"
- "${IRMD_BINARY_DIR}/config.h" @ONLY)
-
-set(IRMD_SOURCES
- "${IRMD_SOURCE_DIR}/ipcp.c"
- "${IRMD_SOURCE_DIR}/configfile.c"
- "${IRMD_SOURCE_DIR}/main.c"
- "${IRMD_SOURCE_DIR}/oap/io.c"
- "${IRMD_SOURCE_DIR}/oap/hdr.c"
- "${IRMD_SOURCE_DIR}/oap/auth.c"
- "${IRMD_SOURCE_DIR}/oap/srv.c"
- "${IRMD_SOURCE_DIR}/oap/cli.c"
- "${IRMD_SOURCE_DIR}/reg/flow.c"
- "${IRMD_SOURCE_DIR}/reg/ipcp.c"
- "${IRMD_SOURCE_DIR}/reg/pool.c"
- "${IRMD_SOURCE_DIR}/reg/proc.c"
- "${IRMD_SOURCE_DIR}/reg/prog.c"
- "${IRMD_SOURCE_DIR}/reg/name.c"
- "${IRMD_SOURCE_DIR}/reg/reg.c"
-)
-
-add_executable(irmd ${IRMD_SOURCES})
-
-target_include_directories(irmd PRIVATE
- "${IRMD_SOURCE_DIR}"
- "${IRMD_BINARY_DIR}"
- "${CMAKE_SOURCE_DIR}/include"
- "${CMAKE_BINARY_DIR}/include")
-
-target_link_libraries(irmd PUBLIC ouroboros-common)
-if (LIBTOML_LIBRARIES)
- target_link_libraries(irmd PUBLIC ${LIBTOML_LIBRARIES})
-endif ()
-
-if (HAVE_TOML)
- target_include_directories(irmd PRIVATE ${LIBTOML_INCLUDE})
-endif ()
-
-include(utils/AddCompileFlags)
-if (CMAKE_BUILD_TYPE MATCHES "Debug*")
- add_compile_flags(irmd -DCONFIG_OUROBOROS_DEBUG)
-endif ()
-
-install(TARGETS irmd RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
diff --git a/cmake/lib.cmake b/cmake/lib.cmake
deleted file mode 100644
index 284c19ee..00000000
--- a/cmake/lib.cmake
+++ /dev/null
@@ -1,11 +0,0 @@
-include(lib/lib)
-include(lib/common)
-include(lib/dev)
-include(lib/irm)
-include(lib/ssm)
-
-configure_file("${LIB_SOURCE_DIR}/config.h.in"
- "${LIB_BINARY_DIR}/config.h" @ONLY)
-
-configure_file("${LIB_SOURCE_DIR}/ssm/ssm.h.in"
- "${LIB_BINARY_DIR}/ssm.h" @ONLY)
diff --git a/cmake/lib/common.cmake b/cmake/lib/common.cmake
deleted file mode 100644
index b0898950..00000000
--- a/cmake/lib/common.cmake
+++ /dev/null
@@ -1,124 +0,0 @@
-# Common library configuration
-
-set(LIB_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/lib")
-set(LIB_BINARY_DIR "${CMAKE_BINARY_DIR}/src/lib")
-
-# Protobuf files
-set_source_files_properties(
- "${LIB_SOURCE_DIR}/pb/model.proto"
- "${LIB_SOURCE_DIR}/pb/ipcp_config.proto"
- "${LIB_SOURCE_DIR}/pb/enroll.proto"
- "${LIB_SOURCE_DIR}/pb/cep.proto"
- "${LIB_SOURCE_DIR}/pb/irm.proto"
- "${LIB_SOURCE_DIR}/pb/ipcp.proto"
- PROPERTIES
- COMPILE_FLAGS "-I${LIB_SOURCE_DIR}/pb"
-)
-
-protobuf_generate_c(MODEL_PROTO_SRCS MODEL_PROTO_HDRS
- "${LIB_SOURCE_DIR}/pb/model.proto")
-protobuf_generate_c(IPCP_CONFIG_PROTO_SRCS IPCP_CONFIG_PROTO_HDRS
- "${LIB_SOURCE_DIR}/pb/ipcp_config.proto")
-protobuf_generate_c(ENROLL_PROTO_SRCS ENROLL_PROTO_HDRS
- "${LIB_SOURCE_DIR}/pb/enroll.proto")
-protobuf_generate_c(CEP_PROTO_SRCS CEP_PROTO_HDRS
- "${LIB_SOURCE_DIR}/pb/cep.proto")
-protobuf_generate_c(IRM_PROTO_SRCS IRM_PROTO_HDRS
- "${LIB_SOURCE_DIR}/pb/irm.proto")
-protobuf_generate_c(IPCP_PROTO_SRCS IPCP_PROTO_HDRS
- "${LIB_SOURCE_DIR}/pb/ipcp.proto")
-
-# Common library source files
-set(SOURCE_FILES_COMMON
- bitmap.c
- btree.c
- crc32.c
- crypt.c
- hash.c
- list.c
- lockfile.c
- logs.c
- md5.c
- notifier.c
- protobuf.c
- qoscube.c
- random.c
- rib.c
- serdes-irm.c
- serdes-oep.c
- sha3.c
- ssm/flow_set.c
- ssm/rbuff.c
- ssm/pool.c
- sockets.c
- tpm.c
- utils.c
-)
-
-# Convert relative paths to absolute
-set(SOURCE_FILES_COMMON_ABS)
-foreach(src ${SOURCE_FILES_COMMON})
- list(APPEND SOURCE_FILES_COMMON_ABS "${LIB_SOURCE_DIR}/${src}")
-endforeach()
-
-if (HAVE_OPENSSL)
- set(OPENSSL_SOURCES "${LIB_SOURCE_DIR}/crypt/openssl.c")
-else()
- set(OPENSSL_SOURCES "")
-endif()
-
-add_library(ouroboros-common SHARED
- ${SOURCE_FILES_COMMON_ABS}
- ${IRM_PROTO_SRCS}
- ${IPCP_PROTO_SRCS}
- ${IPCP_CONFIG_PROTO_SRCS}
- ${MODEL_PROTO_SRCS}
- ${ENROLL_PROTO_SRCS}
- ${OPENSSL_SOURCES})
-
-set_target_properties(ouroboros-common PROPERTIES
- VERSION ${PACKAGE_VERSION}
- SOVERSION ${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR})
-
-include(utils/AddCompileFlags)
-if (CMAKE_BUILD_TYPE MATCHES "Debug*")
- add_compile_flags(ouroboros-common -DCONFIG_OUROBOROS_DEBUG)
-endif ()
-
-target_include_directories(ouroboros-common PUBLIC
- ${LIB_SOURCE_DIR}
- ${LIB_BINARY_DIR}
- ${CMAKE_SOURCE_DIR}/include
- ${CMAKE_BINARY_DIR}/include
- ${CMAKE_BINARY_DIR}
- ${PROTOBUF_C_INCLUDE_DIRS}
- ${SYS_RND_HDR})
-
-if (LIBGCRYPT_INCLUDE_DIR)
- target_include_directories(ouroboros-common PUBLIC ${LIBGCRYPT_INCLUDE_DIR})
-endif ()
-
-if (OPENSSL_INCLUDE_DIR)
- target_include_directories(ouroboros-common PUBLIC ${OPENSSL_INCLUDE_DIR})
-endif ()
-
-
-target_link_libraries(ouroboros-common
- ${LIBRT_LIBRARIES}
- ${LIBPTHREAD_LIBRARIES}
- ${PROTOBUF_C_LIBRARY})
-
-if (OPENSSL_CRYPTO_LIBRARY)
- target_link_libraries(ouroboros-common ${OPENSSL_CRYPTO_LIBRARY})
-endif ()
-
-if (LIBGCRYPT_LIBRARIES)
- target_link_libraries(ouroboros-common ${LIBGCRYPT_LIBRARIES})
-endif ()
-
-if (FUSE_LIBRARIES)
- target_link_libraries(ouroboros-common ${FUSE_LIBRARIES})
-endif ()
-
-install(TARGETS ouroboros-common LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
-
diff --git a/cmake/lib/dev.cmake b/cmake/lib/dev.cmake
deleted file mode 100644
index 21fe140d..00000000
--- a/cmake/lib/dev.cmake
+++ /dev/null
@@ -1,37 +0,0 @@
-set(SOURCE_FILES_DEV
- cep.c
- dev.c
-)
-
-# Convert relative paths to absolute
-set(SOURCE_FILES_DEV_ABS)
-foreach(src ${SOURCE_FILES_DEV})
- list(APPEND SOURCE_FILES_DEV_ABS "${LIB_SOURCE_DIR}/${src}")
-endforeach()
-
-add_library(ouroboros-dev SHARED
- ${SOURCE_FILES_DEV_ABS}
- ${CEP_PROTO_SRCS})
-
-set_target_properties(ouroboros-dev PROPERTIES
- VERSION ${PACKAGE_VERSION}
- SOVERSION ${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR})
-
-if (CMAKE_BUILD_TYPE MATCHES "Debug*")
- add_compile_flags(ouroboros-dev -DCONFIG_OUROBOROS_DEBUG)
-endif ()
-
-target_include_directories(ouroboros-dev PUBLIC
- ${LIB_SOURCE_DIR}
- ${LIB_BINARY_DIR}
- ${CMAKE_SOURCE_DIR}/include
- ${CMAKE_BINARY_DIR}/include
- ${CMAKE_BINARY_DIR}
- ${PROTOBUF_C_INCLUDE_DIRS}
- ${SYS_RND_HDR}
- ${LIBGCRYPT_INCLUDE_DIR}
- ${OPENSSL_INCLUDE_DIR})
-
-target_link_libraries(ouroboros-dev ouroboros-common)
-
-install(TARGETS ouroboros-dev LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/cmake/lib/irm.cmake b/cmake/lib/irm.cmake
deleted file mode 100644
index 5e336b31..00000000
--- a/cmake/lib/irm.cmake
+++ /dev/null
@@ -1,34 +0,0 @@
-set(SOURCE_FILES_IRM
- irm.c
-)
-
-# Convert relative paths to absolute
-set(SOURCE_FILES_IRM_ABS)
-foreach(src ${SOURCE_FILES_IRM})
- list(APPEND SOURCE_FILES_IRM_ABS "${LIB_SOURCE_DIR}/${src}")
-endforeach()
-
-add_library(ouroboros-irm SHARED ${SOURCE_FILES_IRM_ABS})
-
-set_target_properties(ouroboros-irm PROPERTIES
- VERSION ${PACKAGE_VERSION}
- SOVERSION ${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR})
-
-if (CMAKE_BUILD_TYPE MATCHES "Debug*")
- add_compile_flags(ouroboros-irm -DCONFIG_OUROBOROS_DEBUG)
-endif ()
-
-target_include_directories(ouroboros-irm PUBLIC
- ${LIB_SOURCE_DIR}
- ${LIB_BINARY_DIR}
- ${CMAKE_SOURCE_DIR}/include
- ${CMAKE_BINARY_DIR}/include
- ${CMAKE_BINARY_DIR}
- ${PROTOBUF_C_INCLUDE_DIRS}
- ${SYS_RND_HDR}
- ${LIBGCRYPT_INCLUDE_DIR}
- ${OPENSSL_INCLUDE_DIR})
-
-target_link_libraries(ouroboros-irm ouroboros-common)
-
-install(TARGETS ouroboros-irm LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
diff --git a/cmake/package.cmake b/cmake/package.cmake
index d45222dc..71105ee8 100644
--- a/cmake/package.cmake
+++ b/cmake/package.cmake
@@ -10,16 +10,14 @@ message(STATUS "Package URL is: ${PACKAGE_URL}")
message(STATUS "Package bug-report address: ${PACKAGE_BUGREPORT}")
message(STATUS "Package install prefix: ${CMAKE_INSTALL_PREFIX}")
-# Pkg-config files configuration
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ouroboros-dev.pc.in"
- "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-dev.pc" @ONLY)
+configure_file("${CMAKE_SOURCE_DIR}/ouroboros-dev.pc.in"
+ "${CMAKE_BINARY_DIR}/ouroboros-dev.pc" @ONLY)
-configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ouroboros-irm.pc.in"
- "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-irm.pc" @ONLY)
+configure_file("${CMAKE_SOURCE_DIR}/ouroboros-irm.pc.in"
+ "${CMAKE_BINARY_DIR}/ouroboros-irm.pc" @ONLY)
-# CPack packaging configuration
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE_DESCRIPTION}")
-set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
+set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
set(CPACK_PACKAGE_VERSION_MAJOR "${PACKAGE_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PACKAGE_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PACKAGE_VERSION_PATCH}")
diff --git a/cmake/tests.cmake b/cmake/tests.cmake
index e3857cab..edc2987c 100644
--- a/cmake/tests.cmake
+++ b/cmake/tests.cmake
@@ -1,30 +1,30 @@
include(CTest) # Sets BUILD_TESTING by default to on.
include(utils/TestUtils)
+# Test configuration options
+include(config/tests)
include(utils/DisableTestLogging)
-if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
+if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
set(BUILD_TESTS ON)
-else ()
+else()
set(BUILD_TESTS OFF)
endif()
add_custom_target(build_tests)
-if (BUILD_TESTS)
+if(BUILD_TESTS)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
add_dependencies(check build_tests)
+endif()
- # Add test subdirectories
- add_subdirectory(src/lib/tests)
- add_subdirectory(src/lib/ssm/tests)
- add_subdirectory(src/irmd/oap/tests)
- add_subdirectory(src/ipcpd/unicast/pff/tests)
- add_subdirectory(src/ipcpd/unicast/routing/tests)
- add_subdirectory(src/ipcpd/unicast/dir/tests)
- add_subdirectory(src/irmd/reg/tests)
+# Test subdirectories are added from their parent CMakeLists.txt files
+# via add_subdirectory(tests) - keeping tests with their source code
- # Create coverage target if gcov is available
- include(utils/GenCoverage)
- create_coverage_target()
-endif ()
+# Coverage target setup (called after all targets are defined)
+function(setup_coverage_target)
+ if(BUILD_TESTS)
+ include(utils/GenCoverage)
+ create_coverage_target()
+ endif()
+endfunction()
diff --git a/cmake/tools.cmake b/cmake/tools.cmake
deleted file mode 100644
index de1d374c..00000000
--- a/cmake/tools.cmake
+++ /dev/null
@@ -1,8 +0,0 @@
-include(tools/tools)
-include(tools/irm)
-include(tools/ocbr)
-include(tools/oecho)
-include(tools/obc)
-include(tools/oping)
-include(tools/operf)
-include(tools/ovpn)
diff --git a/cmake/tools/irm.cmake b/cmake/tools/irm.cmake
deleted file mode 100644
index c9090a2c..00000000
--- a/cmake/tools/irm.cmake
+++ /dev/null
@@ -1,33 +0,0 @@
-set(IRM_SOURCE_DIR "${TOOLS_SOURCE_DIR}/irm")
-
-set(IRM_SOURCES
- "${IRM_SOURCE_DIR}/irm.c"
- "${IRM_SOURCE_DIR}/irm_bind_program.c"
- "${IRM_SOURCE_DIR}/irm_bind_process.c"
- "${IRM_SOURCE_DIR}/irm_bind_ipcp.c"
- "${IRM_SOURCE_DIR}/irm_ipcp_create.c"
- "${IRM_SOURCE_DIR}/irm_ipcp_destroy.c"
- "${IRM_SOURCE_DIR}/irm_ipcp_bootstrap.c"
- "${IRM_SOURCE_DIR}/irm_ipcp_enroll.c"
- "${IRM_SOURCE_DIR}/irm_ipcp_list.c"
- "${IRM_SOURCE_DIR}/irm_ipcp_connect.c"
- "${IRM_SOURCE_DIR}/irm_ipcp_disconnect.c"
- "${IRM_SOURCE_DIR}/irm_unbind_program.c"
- "${IRM_SOURCE_DIR}/irm_unbind_process.c"
- "${IRM_SOURCE_DIR}/irm_unbind_ipcp.c"
- "${IRM_SOURCE_DIR}/irm_unbind.c"
- "${IRM_SOURCE_DIR}/irm_bind.c"
- "${IRM_SOURCE_DIR}/irm_ipcp.c"
- "${IRM_SOURCE_DIR}/irm_name.c"
- "${IRM_SOURCE_DIR}/irm_name_create.c"
- "${IRM_SOURCE_DIR}/irm_name_destroy.c"
- "${IRM_SOURCE_DIR}/irm_name_reg.c"
- "${IRM_SOURCE_DIR}/irm_name_unreg.c"
- "${IRM_SOURCE_DIR}/irm_name_list.c"
- "${IRM_SOURCE_DIR}/irm_utils.c"
-)
-
-add_executable(irm ${IRM_SOURCES})
-target_include_directories(irm PRIVATE ${TOOLS_INCLUDE_DIRS})
-target_link_libraries(irm PUBLIC ouroboros-irm)
-install(TARGETS irm RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
diff --git a/cmake/tools/obc.cmake b/cmake/tools/obc.cmake
deleted file mode 100644
index 99e001b6..00000000
--- a/cmake/tools/obc.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-add_executable(obc "${TOOLS_SOURCE_DIR}/obc/obc.c")
-target_include_directories(obc PRIVATE ${TOOLS_INCLUDE_DIRS})
-target_link_libraries(obc PUBLIC ouroboros-dev)
-install(TARGETS obc RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cmake/tools/ocbr.cmake b/cmake/tools/ocbr.cmake
deleted file mode 100644
index bab80da8..00000000
--- a/cmake/tools/ocbr.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-add_executable(ocbr "${TOOLS_SOURCE_DIR}/ocbr/ocbr.c")
-target_include_directories(ocbr PRIVATE ${TOOLS_INCLUDE_DIRS})
-target_link_libraries(ocbr PUBLIC ouroboros-dev)
-install(TARGETS ocbr RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cmake/tools/oecho.cmake b/cmake/tools/oecho.cmake
deleted file mode 100644
index 73522731..00000000
--- a/cmake/tools/oecho.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-add_executable(oecho "${TOOLS_SOURCE_DIR}/oecho/oecho.c")
-target_include_directories(oecho PRIVATE ${TOOLS_INCLUDE_DIRS})
-target_link_libraries(oecho PUBLIC ouroboros-dev)
-install(TARGETS oecho RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cmake/tools/operf.cmake b/cmake/tools/operf.cmake
deleted file mode 100644
index f6b2b465..00000000
--- a/cmake/tools/operf.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-add_executable(operf "${TOOLS_SOURCE_DIR}/operf/operf.c")
-target_include_directories(operf PRIVATE ${TOOLS_INCLUDE_DIRS})
-target_link_libraries(operf PUBLIC ouroboros-dev)
-install(TARGETS operf RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cmake/tools/oping.cmake b/cmake/tools/oping.cmake
deleted file mode 100644
index 6bb18132..00000000
--- a/cmake/tools/oping.cmake
+++ /dev/null
@@ -1,4 +0,0 @@
-add_executable(oping "${TOOLS_SOURCE_DIR}/oping/oping.c")
-target_include_directories(oping PRIVATE ${TOOLS_INCLUDE_DIRS})
-target_link_libraries(oping PUBLIC ${LIBM_LIBRARIES} ouroboros-dev)
-install(TARGETS oping RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
diff --git a/cmake/tools/ovpn.cmake b/cmake/tools/ovpn.cmake
deleted file mode 100644
index 331daff9..00000000
--- a/cmake/tools/ovpn.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
- add_executable(ovpn "${TOOLS_SOURCE_DIR}/ovpn/ovpn.c")
- target_include_directories(ovpn PRIVATE ${TOOLS_INCLUDE_DIRS})
- target_link_libraries(ovpn PUBLIC ouroboros-dev)
- install(TARGETS ovpn RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
-endif ()
diff --git a/cmake/tools/tools.cmake b/cmake/tools/tools.cmake
deleted file mode 100644
index 26abdc63..00000000
--- a/cmake/tools/tools.cmake
+++ /dev/null
@@ -1,8 +0,0 @@
-set(TOOLS_SOURCE_DIR "${CMAKE_SOURCE_DIR}/src/tools")
-set(TOOLS_BINARY_DIR "${CMAKE_BINARY_DIR}/src/tools")
-
-set(TOOLS_INCLUDE_DIRS
- ${TOOLS_SOURCE_DIR}
- ${CMAKE_SOURCE_DIR}/include
- ${CMAKE_BINARY_DIR}/include
-)
diff --git a/cmake/utils/AddCompileFlags.cmake b/cmake/utils/AddCompileFlags.cmake
index 8f3877d9..b81ccc67 100644
--- a/cmake/utils/AddCompileFlags.cmake
+++ b/cmake/utils/AddCompileFlags.cmake
@@ -1,17 +1,6 @@
-# - MACRO_ADD_COMPILE_FLAGS(<_target> "flags...")
+# - add_compile_flags(<target> <flags>...)
+# Add compile flags to a target using modern CMake
-# Copyright (c) 2006, Oswald Buddenhagen, <ossi@kde.org>
-#
-# Redistribution and use is allowed according to the terms of the BSD license.
-
-macro(add_compile_flags _target _flg)
-
- get_target_property(_flags ${_target} COMPILE_FLAGS)
- if (_flags)
- set(_flags "${_flags} ${_flg}")
- else (_flags)
- set(_flags "${_flg}")
- endif (_flags)
- set_target_properties(${_target} PROPERTIES COMPILE_FLAGS "${_flags}")
-
-endmacro(add_compile_flags)
+macro(add_compile_flags _target)
+ target_compile_options(${_target} PRIVATE ${ARGN})
+endmacro()
diff --git a/cmake/utils/CMakeUninstall.cmake.in b/cmake/utils/CMakeUninstall.cmake.in
index 985b31b2..b8bba5fd 100644
--- a/cmake/utils/CMakeUninstall.cmake.in
+++ b/cmake/utils/CMakeUninstall.cmake.in
@@ -1,29 +1,21 @@
-if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
+if (NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
-endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
+endif()
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
-foreach(file ${files})
+foreach (file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
- if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
- if(CMAKE_VERSION VERSION_LESS "3.28.0")
- exec_program(
- "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
- OUTPUT_VARIABLE rm_out
- RETURN_VALUE rm_retval
- )
- else()
- execute_process(
- COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
- RESULT_VARIABLE rm_out
- ERROR_VARIABLE rm_retval
- )
- endif ()
- if(NOT "${rm_retval}" STREQUAL "" AND NOT "${rm_retval}" STREQUAL 0)
+ if (IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ execute_process(
+ COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}"
+ RESULT_VARIABLE rm_out
+ ERROR_VARIABLE rm_retval
+ )
+ if (NOT "${rm_retval}" STREQUAL "" AND NOT "${rm_retval}" STREQUAL 0)
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
- endif(NOT "${rm_retval}" STREQUAL "" AND NOT "${rm_retval}" STREQUAL 0)
- else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ endif()
+ else()
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
- endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
-endforeach(file)
+ endif()
+endforeach ()
diff --git a/cmake/utils/CompilerUtils.cmake b/cmake/utils/CompilerUtils.cmake
index 7c8b022f..35548f4f 100644
--- a/cmake/utils/CompilerUtils.cmake
+++ b/cmake/utils/CompilerUtils.cmake
@@ -1,13 +1,13 @@
include(CheckCCompilerFlag)
function(test_and_set_c_compiler_flag_global _flag)
-
string(REGEX REPLACE "-" "_" _sflag ${_flag})
- set(CMAKE_REQUIRED_FLAGS ${_flag})
+ string(REGEX REPLACE "=" "_" _sflag ${_sflag})
+ # Use -Werror during test so clang rejects unknown flags
+ set(CMAKE_REQUIRED_FLAGS "-Werror ${_flag}")
check_c_compiler_flag(${_flag} COMPILER_SUPPORTS_FLAG_${_sflag})
if(COMPILER_SUPPORTS_FLAG_${_sflag})
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_flag}" PARENT_SCOPE)
+ add_compile_options(${_flag})
endif()
-
-endfunction(test_and_set_c_compiler_flag_global)
+endfunction()
diff --git a/cmake/utils/DebugTargets.cmake b/cmake/utils/DebugTargets.cmake
new file mode 100644
index 00000000..78899213
--- /dev/null
+++ b/cmake/utils/DebugTargets.cmake
@@ -0,0 +1,16 @@
+# Utility functions for Ouroboros target configuration
+set(OUROBOROS_DEBUG_CONFIGS
+ Debug
+ DebugASan
+ DebugTSan
+ DebugLSan
+ DebugUSan
+ DebugAnalyzer
+)
+
+# Add CONFIG_OUROBOROS_DEBUG definition for debug build types
+function(ouroboros_target_debug_definitions target)
+ list(JOIN OUROBOROS_DEBUG_CONFIGS "," _configs)
+ target_compile_definitions(${target} PRIVATE
+ "$<$<CONFIG:${_configs}>:CONFIG_OUROBOROS_DEBUG>")
+endfunction()
diff --git a/cmake/utils/DisableTestLogging.cmake b/cmake/utils/DisableTestLogging.cmake
index a7e90b38..40c16668 100644
--- a/cmake/utils/DisableTestLogging.cmake
+++ b/cmake/utils/DisableTestLogging.cmake
@@ -1,22 +1,11 @@
-set(DISABLE_TESTS_LOGGING TRUE CACHE BOOL "Disable Ouroboros log output in tests")
-if (DISABLE_TESTS_LOGGING)
- message(STATUS "Ouroboros logging in test output disabled")
-else ()
- message(STATUS "Ouroboros logging in test output enabled")
-endif ()
-
-set(DISABLE_TESTS_CORE_DUMPS TRUE CACHE BOOL "Enable core dumps for tests (useful for debugging)")
-if (DISABLE_TESTS_CORE_DUMPS)
- message(STATUS "Core dumps in tests enabled")
-else ()
- message(STATUS "Core dumps in tests disabled")
-endif ()
+# Macro to apply test logging settings to a target
+# Configuration options are in cmake/config/tests.cmake
macro(disable_test_logging_for_target target)
- if (DISABLE_TESTS_LOGGING)
+ if(DISABLE_TESTS_LOGGING)
target_compile_definitions(${target} PRIVATE OUROBOROS_DISABLE_LOGGING)
- endif ()
- if (DISABLE_TESTS_CORE_DUMPS)
+ endif()
+ if(DISABLE_TESTS_CORE_DUMPS)
target_compile_definitions(${target} PRIVATE DISABLE_TESTS_CORE_DUMPS)
- endif ()
+ endif()
endmacro()
diff --git a/cmake/utils/FindProtobufC.cmake b/cmake/utils/FindProtobufC.cmake
index ff892b5b..4632dfcb 100644
--- a/cmake/utils/FindProtobufC.cmake
+++ b/cmake/utils/FindProtobufC.cmake
@@ -1,22 +1,22 @@
-function(PROTOBUF_GENERATE_C SRCS HDRS)
- if (NOT ARGN)
- message(SEND_ERROR "Error: PROTOBUF_GENERATE_C() called without any proto files")
+function(protobuf_generate_c SRCS HDRS)
+ if(NOT ARGN)
+ message(SEND_ERROR "Error: protobuf_generate_c() called without any proto files")
return()
- endif ()
+ endif()
- if (PROTOBUF_GENERATE_C_APPEND_PATH)
+ if(PROTOBUF_GENERATE_C_APPEND_PATH)
# Create an include path for each file specified
foreach (FIL ${ARGN})
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
get_filename_component(ABS_PATH ${ABS_FIL} PATH)
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
- if (${_contains_already} EQUAL -1)
+ if(${_contains_already} EQUAL -1)
list(APPEND _protobuf_include_path -I ${ABS_PATH})
- endif ()
+ endif()
endforeach ()
- else ()
+ else()
set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
- endif ()
+ endif()
set(${SRCS})
set(${HDRS})
@@ -42,33 +42,37 @@ function(PROTOBUF_GENERATE_C SRCS HDRS)
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
endfunction()
-# By default have PROTOBUF_GENERATE_C macro pass -I to protoc
+# By default have protobuf_generate_c function pass -I to protoc
# for each directory where a proto file is referenced.
-if (NOT DEFINED PROTOBUF_GENERATE_C_APPEND_PATH)
+if(NOT DEFINED PROTOBUF_GENERATE_C_APPEND_PATH)
set(PROTOBUF_GENERATE_C_APPEND_PATH TRUE)
-endif ()
+endif()
-# Find library
find_library(PROTOBUF_C_LIBRARY
NAMES libprotobuf-c.so libprotobuf-c libprotobuf-c.dylib
)
mark_as_advanced(PROTOBUF_C_LIBRARY)
-# Find the include directory
find_path(PROTOBUF_C_INCLUDE_DIR
google/protobuf-c/protobuf-c.h
)
mark_as_advanced(PROTOBUF_C_INCLUDE_DIR)
-# Find the protoc-c Executable
find_program(PROTOBUF_PROTOC_C_EXECUTABLE
NAMES protoc protoc-c
DOC "The Google Protocol Buffers C Compiler"
)
mark_as_advanced(PROTOBUF_PROTOC_C_EXECUTABLE)
-find_package(PackageHandleStandardArgs)
+include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ProtobufC DEFAULT_MSG
PROTOBUF_C_LIBRARY PROTOBUF_C_INCLUDE_DIR PROTOBUF_PROTOC_C_EXECUTABLE)
set(PROTOBUF_C_INCLUDE_DIRS ${PROTOBUF_C_INCLUDE_DIR})
+
+if(ProtobufC_FOUND AND NOT TARGET ProtobufC::ProtobufC)
+ add_library(ProtobufC::ProtobufC UNKNOWN IMPORTED)
+ set_target_properties(ProtobufC::ProtobufC PROPERTIES
+ IMPORTED_LOCATION "${PROTOBUF_C_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${PROTOBUF_C_INCLUDE_DIR}")
+endif()
diff --git a/cmake/utils/GenCoverage.cmake b/cmake/utils/GenCoverage.cmake
index 65f5d8ba..0ae11ee8 100644
--- a/cmake/utils/GenCoverage.cmake
+++ b/cmake/utils/GenCoverage.cmake
@@ -57,8 +57,8 @@ function(create_informational_target)
)
endfunction()
-macro(create_coverage_target)
- if(HAVE_GCOV AND ENABLE_COVERAGE)
+function(create_coverage_target)
+ if(HAVE_GCOV AND NOT DISABLE_COVERAGE)
get_html_coverage_commands(HTML_COVERAGE_COMMANDS)
add_custom_target(coverage
@@ -91,4 +91,4 @@ macro(create_coverage_target)
"Coverage not available"
)
endif()
-endmacro()
+endfunction()
diff --git a/cmake/utils/TestUtils.cmake b/cmake/utils/TestUtils.cmake
index e40bdda1..e602690c 100644
--- a/cmake/utils/TestUtils.cmake
+++ b/cmake/utils/TestUtils.cmake
@@ -3,4 +3,36 @@ function(compute_test_prefix)
file(RELATIVE_PATH _prefix "${CMAKE_SOURCE_DIR}/src" "${CMAKE_CURRENT_SOURCE_DIR}")
string(REGEX REPLACE "/tests$" "" _prefix "${_prefix}")
set(TEST_PREFIX "${_prefix}" PARENT_SCOPE)
-endfunction(compute_test_prefix)
+endfunction()
+
+# Register tests from a test executable with the test framework
+# Usage: ouroboros_register_tests(TARGET <target> TESTS <test_list> [ENVIRONMENT <env>])
+# The TESTS argument should be the test list variable created by create_test_sourcelist
+function(ouroboros_register_tests)
+ cmake_parse_arguments(PARSE_ARGV 0 ARG "" "TARGET;ENVIRONMENT" "TESTS")
+
+ if(NOT ARG_TARGET)
+ message(FATAL_ERROR "ouroboros_register_tests: TARGET required")
+ endif()
+
+ if(NOT ARG_TESTS)
+ message(FATAL_ERROR "ouroboros_register_tests: TESTS required")
+ endif()
+
+ # First entry is the test driver, skip it
+ set(_tests ${ARG_TESTS})
+ list(POP_FRONT _tests)
+
+ foreach (test_src ${_tests})
+ get_filename_component(test_name ${test_src} NAME_WE)
+ add_test(${TEST_PREFIX}/${test_name}
+ ${CMAKE_CURRENT_BINARY_DIR}/${ARG_TARGET} ${test_name})
+ # All Ouroboros tests support skip return code
+ set_property(TEST ${TEST_PREFIX}/${test_name} PROPERTY SKIP_RETURN_CODE 1)
+ # Optional environment variables
+ if(ARG_ENVIRONMENT)
+ set_property(TEST ${TEST_PREFIX}/${test_name}
+ PROPERTY ENVIRONMENT "${ARG_ENVIRONMENT}")
+ endif()
+ endforeach ()
+endfunction()