summaryrefslogtreecommitdiffstats
path: root/contrib/libev/CMakeLists.txt
blob: b2d33fe4918a7c68ad486016e46921c9ce2540aa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
SET(LIBEVSRC	ev.c)

CHECK_INCLUDE_FILES(sys/types.h HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILES(sys/inotify.h HAVE_SYS_INOTIFY_H)
CHECK_INCLUDE_FILES(sys/epoll.h HAVE_SYS_EPOLL_H)
CHECK_INCLUDE_FILES("sys/types.h;sys/event.h;sys/time.h" HAVE_SYS_EVENT_H)
CHECK_INCLUDE_FILES(sys/queue.h HAVE_SYS_QUEUE_H)
CHECK_INCLUDE_FILES(sys/stat.h HAVE_SYS_STAT_H)
CHECK_INCLUDE_FILES(sys/signalfd.h HAVE_SYS_SIGNALFD_H)
CHECK_INCLUDE_FILES(port.h HAVE_PORT_H)
CHECK_INCLUDE_FILES(poll.h HAVE_POLL_H)
CHECK_INCLUDE_FILES(memory.h HAVE_MEMORY_H)
CHECK_INCLUDE_FILES(sys/select.h HAVE_SYS_SELECT_H)
CHECK_INCLUDE_FILES(sys/eventfd.h HAVE_SYS_EVENTFD_H)
CHECK_INCLUDE_FILES(sys/timerfd.h HAVE_SYS_TIMERFD_H)
CHECK_INCLUDE_FILES(linux/fs.h HAVE_LINUX_FS_H)
CHECK_INCLUDE_FILES(linux/aio_abi.h HAVE_LINUX_AIO_ABI_H)

IF(HAVE_SYS_INOTIFY_H)
	CHECK_SYMBOL_EXISTS(inotify_init "sys/types.h;sys/inotify.h" HAVE_INOTIFY_INIT)
ENDIF()
IF(HAVE_SYS_EPOLL_H)
	CHECK_SYMBOL_EXISTS(epoll_ctl "sys/types.h;sys/epoll.h" HAVE_EPOLL_CTL)
ENDIF()
IF(HAVE_SYS_EVENT_H)
	CHECK_SYMBOL_EXISTS(kqueue "sys/types.h;sys/event.h;sys/time.h" HAVE_KQUEUE)
ENDIF()
IF(HAVE_PORT_H)
	CHECK_SYMBOL_EXISTS(port_create port.h HAVE_PORT_CREATE)
ENDIF()
IF(HAVE_POLL_H)
	CHECK_SYMBOL_EXISTS(poll poll.h HAVE_POLL)
ENDIF()
IF(HAVE_SYS_SELECT_H)
	CHECK_SYMBOL_EXISTS(select sys/select.h HAVE_SELECT)
ENDIF()
IF(HAVE_SYS_EVENTFD_H)
	CHECK_SYMBOL_EXISTS(eventfd sys/eventfd.h HAVE_EVENTFD)
ENDIF()
IF(HAVE_SYS_SIGNALFD_H)
	CHECK_SYMBOL_EXISTS(signalfd sys/signalfd.h HAVE_SIGNALFD)
ENDIF()
IF(HAVE_SYS_TIMERFD_H)
	CHECK_SYMBOL_EXISTS(timerfd_create sys/timerfd.h HAVE_TIMERFD)
ENDIF()
IF(HAVE_LINUX_FS_H)
	CHECK_SYMBOL_EXISTS(RWF_SUPPORTED linux/fs.h HAVE_KERNEL_RWF_T)
ENDIF()
CHECK_SYMBOL_EXISTS(time.h nanosleep HAVE_NANOSLEEP)

# check first without rt
CHECK_FUNCTION_EXISTS(clock_gettime HAVE_CLOCK_GETTIME)

CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT)
# then check with rt
CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_CLOCK_GETTIME)
CHECK_LIBRARY_EXISTS(m ceil "" HAVE_LIBM)

CONFIGURE_FILE(config.h.in libev-config.h)

IF(ENABLE_STATIC MATCHES "ON")
	ADD_LIBRARY(rspamd-ev STATIC ${LIBEVSRC})
ELSE()
	ADD_LIBRARY(rspamd-ev SHARED ${LIBEVSRC})
ENDIF()
target_link_libraries(rspamd-ev "${RSPAMD_REQUIRED_LIBRARIES}")
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
ADD_DEFINITIONS("-DEV_CONFIG_H=\"libev-config.h\""
		-DEV_MULTIPLICITY=1
		-DEV_USE_FLOOR=1
		-DEV_NO_THREADS=1 # We do not have threads in Rspamd!
		-DEV_FEATURES=127 # Enable all features
		)
IF(HAVE_EVENTFD)
	ADD_DEFINITIONS(-DEV_USE_EVENTFD=1)
ENDIF()

IF(ENABLE_FULL_DEBUG MATCHES "ON")
	ADD_DEFINITIONS(-DEV_VERIFY=3)
ENDIF()

INSTALL(TARGETS rspamd-ev LIBRARY DESTINATION ${RSPAMD_LIBDIR})