cmake_minimum_required(VERSION 3.0 FATAL_ERROR) project(libev C) set (libev_VERSION_MAJOR 4) set (libev_VERSION_MINOR 33) set(VERSION TRUE) include_directories("${PROJECT_SOURCE_DIR}") include_directories("${PROJECT_BINARY_DIR}") include(CheckSymbolExists) set(LIBEV_SOURCES ev.c event.c) check_symbol_exists(epoll_ctl sys/epoll.h HAVE_EPOLL_CTL) check_symbol_exists(clock_gettime time.h HAVE_CLOCK_GETTIME) find_file(HAVE_DLFCN_H dlfcn.h) check_symbol_exists(eventfd sys/eventfd.h HAVE_EVENTFD) set(CMAKE_REQUIRED_LIBRARIES -lm) check_symbol_exists(floor math.h HAVE_FLOOR) check_symbol_exists(inotify_init sys/inotify.h HAVE_INOTIFY_INIT) find_file(HAVE_INTTYPES_H inttypes.h) check_symbol_exists(kqueue sys/time.h;sys/types.h;sys/event.h HAVE_KQUEUE) find_library(HAVE_LIBRT librt.so) find_file(HAVE_MEMORY_H memory.h) check_symbol_exists(nanosleep time.h HAVE_NANOSLEEP) check_symbol_exists(poll poll.h HAVE_POLL) find_file(HAVE_POLL_H poll.h) check_symbol_exists(port_create port.h HAVE_PORT_CREATE) find_file(HAVE_PORT_H port.h) check_symbol_exists(select sys/select.h HAVE_SELECT) check_symbol_exists(signalfd sys/signalfd.h HAVE_SIGNALFD) find_file(HAVE_STDINT_H stdint.h) find_file(HAVE_STDLIB_H stdlib.h) find_file(HAVE_STRINGS_H strings.h) find_file(HAVE_STRING_H string.h) find_file(HAVE_SYS_EPOLL_H sys/epoll.h) find_file(HAVE_SYS_EVENTFD_H sys/eventfd.h) find_file(HAVE_SYS_EVENT_H sys/event.h) find_file(HAVE_SYS_INOTIFY_H sys/inotify.h) find_file(HAVE_SYS_SELECT_H sys/select.h) find_file(HAVE_SYS_SIGNALFD_H sys/signalfd.h) find_file(HAVE_SYS_STAT_H sys/stat.h) find_file(HAVE_SYS_TYPES_H sys/types.h) find_file(HAVE_UNISTD_H unistd.h) find_file(HAVE_LINUX_AIO_ABI_H linux/aio_abi.h) check_symbol_exists(kernel_rwf_t linux/fs.h HAVE_KERNEL_RWF_T) find_file(HAVE_LINUX_FS_H linux/fs.h) find_file(HAVE_SYS_TIMERFD_H sys/timerfd.h) configure_file ( "${PROJECT_SOURCE_DIR}/cmake_config.h.in" "${PROJECT_BINARY_DIR}/config.h" ) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DHAVE_CONFIG_H -fPIC -DPIC") add_library(ev STATIC ${LIBEV_SOURCES})