Skip to content

Commit ae27169

Browse files
committed
CMake: Add cmake module to find libepoll-shim library
1 parent 9437e55 commit ae27169

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# LIBEPOLLSHIM_FOUND - System has libepoll-shim
2+
# LIBEPOLLSHIM_INCLUDE_DIRS - The libepoll-shim include directories
3+
# LIBEPOLLSHIM_LIBRARIES - The libraries needed to use libepoll-shim
4+
# LIBEPOLLSHIM_DEFINITIONS - Compiler switches required for using libepoll-shim
5+
6+
# use pkg-config to get the directories and then use these values
7+
# in the find_path() and find_library() calls
8+
find_package(PkgConfig)
9+
if (PKG_CONFIG_FOUND)
10+
pkg_check_modules(PC_EPOLLSHIM QUIET epoll-shim)
11+
set(LIBEPOLLSHIM_DEFINITIONS ${PC_EPOLLSHIM_CFLAGS_OTHER})
12+
endif()
13+
14+
find_path(
15+
EPOLLSHIM_INCLUDE_DIR libepoll-shim/sys/epoll.h
16+
HINTS ${PC_EPOLLSHIM_INCLUDEDIR} ${PC_EPOLLSHIM_INCLUDE_DIRS}
17+
PATH_SUFFIXES include
18+
)
19+
find_library(
20+
EPOLLSHIM_LIBRARY NAMES epoll-shim libepoll-shim
21+
HINTS ${PC_EPOLLSHIM_LIBDIR} ${PC_EPOLLSHIM_LIBRARY_DIRS}
22+
PATH_SUFFIXES lib lib64
23+
)
24+
25+
if (PC_EPOLLSHIM_VERSION)
26+
# Version extracted from pkg-config
27+
set(EPOLLSHIM_VERSION_STRING ${PC_EPOLLSHIM_VERSION})
28+
endif()
29+
30+
# handle the QUIETLY and REQUIRED arguments and set LIBEPOLLSHIM_FOUND to TRUE
31+
# if all listed variables are TRUE
32+
include(FindPackageHandleStandardArgs)
33+
find_package_handle_standard_args(LibEpollShim
34+
REQUIRED_VARS EPOLLSHIM_LIBRARY EPOLLSHIM_INCLUDE_DIR
35+
VERSION_VAR EPOLLSHIM_VERSION_STRING
36+
)
37+
38+
set(LIBEPOLLSHIM_LIBRARIES ${EPOLLSHIM_LIBRARY})
39+
set(LIBEPOLLSHIM_INCLUDE_DIRS ${EPOLLSHIM_INCLUDE_DIR}/libepoll-shim)
40+
mark_as_advanced(EPOLLSHIM_INCLUDE_DIR EPOLLSHIM_LIBRARY)

0 commit comments

Comments
 (0)