From 5ed27ef8b6362ee2a30dd8f6094fa8ca32a97439 Mon Sep 17 00:00:00 2001 From: Tom Jones Date: Mon, 29 Jan 2024 14:38:19 +0000 Subject: build: Discover libepoll-shim on FreeBSD FreeBSD doesn't offer epoll, but an implementation which uses kqueue is available as an external library. On FreeBSD in subsystems which require epoll have cmake look for libepoll-shim. Type: improvement Change-Id: Iafd5406a9e2ebaa53fd94034489ffbbf87a7d040 Signed-off-by: Tom Jones --- src/CMakeLists.txt | 15 +++++++++++++++ src/vlib/CMakeLists.txt | 2 +- src/vpp/CMakeLists.txt | 6 +++--- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 9415c4d44fb..68d0a4fe64e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -244,6 +244,21 @@ include(cmake/library.cmake) include(cmake/exec.cmake) include(cmake/plugin.cmake) +############################################################################## +# FreeBSD - use epoll-shim +############################################################################## +set(EPOLL_LIB "") +if("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") + find_path(EPOLL_SHIM_INCLUDE_DIR NAMES sys/epoll.h HINTS /usr/local/include/libepoll-shim) + find_library(EPOLL_SHIM_LIB NAMES epoll-shim HINTS /usr/local/lib) + + if(EPOLL_SHIM_INCLUDE_DIR AND EPOLL_SHIM_LIB) + message(STATUS "Found epoll-shim in ${EPOLL_SHIM_INCLUDE_DIR}") + include_directories(${EPOLL_SHIM_INCLUDE_DIR}) + string(JOIN " " EPOLL_LIB "${EPOLL_SHIM_LIB}") + endif() +endif() + ############################################################################## # subdirs - order matters ############################################################################## diff --git a/src/vlib/CMakeLists.txt b/src/vlib/CMakeLists.txt index 61e8ba7dd78..7ec9b2050e9 100644 --- a/src/vlib/CMakeLists.txt +++ b/src/vlib/CMakeLists.txt @@ -153,7 +153,7 @@ add_vpp_library(vlib API_FILES pci/pci_types.api - LINK_LIBRARIES vppinfra svm ${CMAKE_DL_LIBS} + LINK_LIBRARIES vppinfra svm ${CMAKE_DL_LIBS} ${EPOLL_LIB} DEPENDS api_headers ) diff --git a/src/vpp/CMakeLists.txt b/src/vpp/CMakeLists.txt index 37f57ac7823..84144e4d059 100644 --- a/src/vpp/CMakeLists.txt +++ b/src/vpp/CMakeLists.txt @@ -90,7 +90,7 @@ endif() add_vpp_executable(vpp ENABLE_EXPORTS SOURCES ${VPP_SOURCES} - LINK_LIBRARIES svm vlib vppinfra vlibmemory vnet Threads::Threads ${CMAKE_DL_LIBS} + LINK_LIBRARIES svm vlib vppinfra vlibmemory vnet Threads::Threads ${CMAKE_DL_LIBS} ${EPOLL_LIB} DEPENDS vpp_version_h api_headers ) @@ -99,7 +99,7 @@ add_vpp_executable(vpp ############################################################################## add_vpp_executable(vppctl SOURCES app/vppctl.c - LINK_LIBRARIES vppinfra + LINK_LIBRARIES vppinfra ${EPOLL_LIB} ) ############################################################################## @@ -122,7 +122,7 @@ add_vpp_executable(vpp_get_stats add_vpp_executable(vpp_prometheus_export SOURCES app/vpp_prometheus_export.c - LINK_LIBRARIES vppapiclient vppinfra svm vlibmemoryclient + LINK_LIBRARIES vppapiclient vppinfra svm vlibmemoryclient ${EPOLL_LIB} DEPENDS api_headers ) -- cgit 1.2.3-korg