summaryrefslogtreecommitdiff
path: root/cmake/dependencies/system
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/dependencies/system')
-rw-r--r--cmake/dependencies/system/explicit_bzero.cmake4
-rw-r--r--cmake/dependencies/system/fuse.cmake46
-rw-r--r--cmake/dependencies/system/libraries.cmake17
-rw-r--r--cmake/dependencies/system/liburcu.cmake45
-rw-r--r--cmake/dependencies/system/protobufc.cmake13
-rw-r--r--cmake/dependencies/system/robustmutex.cmake18
-rw-r--r--cmake/dependencies/system/sysrandom.cmake14
7 files changed, 157 insertions, 0 deletions
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..007d82fd
--- /dev/null
+++ b/cmake/dependencies/system/fuse.cmake
@@ -0,0 +1,46 @@
+# Try pkg-config first, fall back to find_library
+# Use FUSE_PKG prefix to avoid collision with FUSE_PREFIX
+if(PkgConfig_FOUND)
+ pkg_check_modules(FUSE_PKG QUIET IMPORTED_TARGET fuse>=2.6)
+ if(FUSE_PKG_FOUND AND NOT TARGET Fuse::Fuse)
+ add_library(Fuse::Fuse ALIAS PkgConfig::FUSE_PKG)
+ endif()
+endif()
+
+if(NOT FUSE_PKG_FOUND)
+ find_library(FUSE_PKG_LIBRARIES fuse QUIET)
+ if(FUSE_PKG_LIBRARIES)
+ set(FUSE_PKG_FOUND TRUE)
+ if(NOT TARGET Fuse::Fuse)
+ add_library(Fuse::Fuse UNKNOWN IMPORTED)
+ set_target_properties(Fuse::Fuse PROPERTIES
+ IMPORTED_LOCATION "${FUSE_PKG_LIBRARIES}")
+ endif()
+ endif()
+endif()
+
+if(FUSE_PKG_FOUND)
+ set(DISABLE_FUSE FALSE CACHE BOOL "Disable FUSE support")
+ if(NOT DISABLE_FUSE)
+ if(FUSE_PKG_VERSION)
+ message(STATUS "FUSE support enabled (version ${FUSE_PKG_VERSION})")
+ else()
+ message(STATUS "FUSE support enabled")
+ endif()
+ set(HAVE_FUSE TRUE CACHE INTERNAL "FUSE filesystem support available")
+ set(FUSE_PREFIX "/tmp/ouroboros" CACHE STRING
+ "Mountpoint for RIB filesystem")
+ 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_PKG_LIBRARIES "")
+endif()
+
+mark_as_advanced(FUSE_PKG_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/system/liburcu.cmake b/cmake/dependencies/system/liburcu.cmake
new file mode 100644
index 00000000..89a7ab12
--- /dev/null
+++ b/cmake/dependencies/system/liburcu.cmake
@@ -0,0 +1,45 @@
+# Userspace RCU (liburcu) - optional. Enables lock-free data-plane key
+# rotation; absent => per-flow rwlock fallback. The "bulletproof" flavour
+# (urcu-bp) auto-registers reader threads, so application threads need no
+# RCU lifecycle plumbing.
+if(PkgConfig_FOUND)
+ pkg_check_modules(URCU_PKG QUIET IMPORTED_TARGET liburcu-bp)
+ if(URCU_PKG_FOUND AND NOT TARGET Urcu::Urcu)
+ add_library(Urcu::Urcu ALIAS PkgConfig::URCU_PKG)
+ endif()
+endif()
+
+if(NOT URCU_PKG_FOUND)
+ find_library(URCU_BP_LIBRARY urcu-bp QUIET)
+ find_library(URCU_COMMON_LIBRARY urcu-common QUIET)
+ find_path(URCU_INCLUDE_DIR urcu-bp.h QUIET)
+ if(URCU_BP_LIBRARY AND URCU_COMMON_LIBRARY AND URCU_INCLUDE_DIR)
+ set(URCU_PKG_FOUND TRUE)
+ if(NOT TARGET Urcu::Urcu)
+ add_library(Urcu::Urcu INTERFACE IMPORTED)
+ set_target_properties(Urcu::Urcu PROPERTIES
+ INTERFACE_LINK_LIBRARIES "${URCU_BP_LIBRARY};${URCU_COMMON_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${URCU_INCLUDE_DIR}")
+ endif()
+ endif()
+endif()
+
+if(URCU_PKG_FOUND)
+ set(DISABLE_LIBURCU FALSE CACHE BOOL "Disable liburcu (RCU) support")
+ if(NOT DISABLE_LIBURCU)
+ if(URCU_PKG_VERSION)
+ message(STATUS "liburcu (RCU) support enabled (version ${URCU_PKG_VERSION})")
+ else()
+ message(STATUS "liburcu (RCU) support enabled")
+ endif()
+ set(HAVE_LIBURCU TRUE CACHE INTERNAL "Userspace RCU (liburcu) available")
+ else()
+ message(STATUS "liburcu (RCU) support disabled by user")
+ unset(HAVE_LIBURCU CACHE)
+ endif()
+else()
+ message(STATUS "Install liburcu (urcu-bp) for lock-free data-plane re-keying")
+ unset(HAVE_LIBURCU CACHE)
+endif()
+
+mark_as_advanced(URCU_BP_LIBRARY URCU_COMMON_LIBRARY URCU_INCLUDE_DIR)
diff --git a/cmake/dependencies/system/protobufc.cmake b/cmake/dependencies/system/protobufc.cmake
new file mode 100644
index 00000000..b7e0062a
--- /dev/null
+++ b/cmake/dependencies/system/protobufc.cmake
@@ -0,0 +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
+ AND PROTOBUF_PROTOC_C_EXECUTABLE))
+ message(FATAL_ERROR "Protobuf C compiler required but not found. "
+ "Please install Google Protocol Buffers.")
+else()
+ message(STATUS "Found protobuf C compiler in ${PROTOBUF_PROTOC_C_EXECUTABLE}")
+endif()
+
+# Note: Include dirs are added per-target via target_include_directories
+# using ${PROTOBUF_C_INCLUDE_DIRS}
diff --git a/cmake/dependencies/system/robustmutex.cmake b/cmake/dependencies/system/robustmutex.cmake
new file mode 100644
index 00000000..89b7325b
--- /dev/null
+++ b/cmake/dependencies/system/robustmutex.cmake
@@ -0,0 +1,18 @@
+list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200809L)
+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)
+ set(DISABLE_ROBUST_MUTEXES FALSE CACHE BOOL "Disable robust mutex support")
+ if(NOT DISABLE_ROBUST_MUTEXES)
+ message(STATUS "Robust mutex support enabled")
+ set(HAVE_ROBUST_MUTEX TRUE)
+ else()
+ message(STATUS "Robust mutex support disabled by user")
+ unset(HAVE_ROBUST_MUTEX)
+ endif()
+else()
+ message(STATUS "Robust mutex support not available")
+ unset(HAVE_ROBUST_MUTEX)
+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)