@@ -4,6 +4,9 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
44set (THREADS_PREFER_PTHREAD_FLAG ON )
55find_package (Threads REQUIRED )
66
7+ find_package (tree -macros REQUIRED )
8+ find_package (queue-macros REQUIRED )
9+
710add_library (rwlock OBJECT rwlock.c )
811set_property (TARGET rwlock PROPERTY POSITION_INDEPENDENT_CODE ON )
912target_link_libraries (rwlock PUBLIC Threads::Threads )
@@ -18,11 +21,15 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
1821 return ()
1922endif ()
2023
21- find_package (tree -macros REQUIRED )
22- find_package (queue-macros REQUIRED )
24+ add_library (wrap OBJECT wrap.c )
25+ set_property (TARGET wrap PROPERTY POSITION_INDEPENDENT_CODE ON )
26+ target_link_libraries (wrap PUBLIC Threads::Threads )
27+ target_include_directories (wrap
28+ PUBLIC $<BUILD_INTERFACE :${CMAKE_CURRENT_LIST_DIR} >)
2329
2430macro (add_compat_target _name _condition )
2531 add_library (compat_${_name} OBJECT compat_${_name}.c )
32+ target_link_libraries (compat_${_name} PUBLIC wrap )
2633 set_property (TARGET compat_${_name} PROPERTY POSITION_INDEPENDENT_CODE ON )
2734 target_compile_options (
2835 compat_${_name}
@@ -39,12 +46,13 @@ macro(add_compat_target _name _condition)
3946endmacro ()
4047
4148include (CheckSymbolExists )
49+
4250# FreeBSD 13 and NetBSD 10 support native eventfd descriptors. NetBSD 10
4351# supports native timerfd descriptors. Prefer them if available.
4452check_symbol_exists (eventfd "sys/eventfd.h" HAVE_EVENTFD )
4553check_symbol_exists (timerfd_create "sys/timerfd.h" HAVE_TIMERFD )
4654
47- check_symbol_exists (kqueue1 "sys/event.h" HAVE_KQUEUE1 )
55+ check_symbol_exists (kqueue1 "sys/event.h;sys/time.h " HAVE_KQUEUE1 )
4856add_compat_target (kqueue1 "NOT;HAVE_KQUEUE1" )
4957check_symbol_exists (sigandset "signal.h" HAVE_SIGANDSET )
5058check_symbol_exists (sigorset "signal.h" HAVE_SIGORSET )
@@ -71,6 +79,14 @@ if(NOT ALLOWS_ONESHOT_TIMERS_WITH_TIMEOUT_ZERO)
7179 evfilt_timer_quirks
7280 INTERFACE QUIRK_EVFILT_TIMER_DISALLOWS_ONESHOT_TIMEOUT_ZERO )
7381endif ()
82+ add_compat_target (pipe2 "APPLE" )
83+ add_compat_target (socket "APPLE" )
84+ add_compat_target (socketpair "APPLE" )
85+ add_compat_target (itimerspec "APPLE" )
86+ add_compat_target (sem "APPLE" )
87+ add_compat_target (ppoll "APPLE" )
88+
89+ target_link_libraries (rwlock PUBLIC $<BUILD_INTERFACE :compat_enable_sem >)
7490
7591add_library (
7692 epoll-shim
@@ -80,8 +96,7 @@ add_library(
8096 kqueue_event.c
8197 signalfd.c
8298 signalfd_ctx.c
83- timespec_util.c
84- wrap.c )
99+ timespec_util.c )
85100if (NOT HAVE_EVENTFD)
86101 target_sources (epoll-shim PRIVATE eventfd.c eventfd_ctx.c )
87102endif ()
@@ -94,11 +109,14 @@ target_link_libraries(
94109 epoll-shim
95110 PRIVATE Threads::Threads #
96111 $<BUILD_INTERFACE :queue -macros ::queue -macros >
97- $<BUILD_INTERFACE :tree -macros ::tree -macros >
112+ $<BUILD_INTERFACE :tree -macros ::tree -macros > #
98113 $<BUILD_INTERFACE :evfilt_timer_quirks >
99114 $<BUILD_INTERFACE :compat_enable_kqueue1 >
115+ $<BUILD_INTERFACE :compat_enable_ppoll >
116+ $<BUILD_INTERFACE :compat_enable_itimerspec >
100117 $<BUILD_INTERFACE :compat_enable_sigops >
101- $<BUILD_INTERFACE :rwlock >)
118+ $<BUILD_INTERFACE :rwlock >
119+ $<BUILD_INTERFACE :wrap >)
102120if (HAVE_TIMERFD)
103121 target_compile_definitions (epoll-shim PRIVATE HAVE_TIMERFD )
104122endif ()
0 commit comments