Changeset View
Changeset View
Standalone View
Standalone View
cmake/modules/Findepoll.cmake
- This file was added.
1 | #.rest: | ||||
---|---|---|---|---|---|
2 | # FindEpoll | ||||
3 | # -------------- | ||||
4 | # | ||||
5 | # Try to find epoll or epoll-shim on this system. This finds: | ||||
6 | # - some shim on Unix like systems (FreeBSD), or | ||||
7 | # - the kernel's epoll on Linux systems. | ||||
8 | # | ||||
9 | # This will define the following variables: | ||||
10 | # | ||||
11 | # ``epoll_FOUND`` | ||||
12 | # True if epoll is available | ||||
13 | # ``epoll_LIBRARIES`` | ||||
14 | # This has to be passed to target_link_libraries() | ||||
15 | # ``epoll_INCLUDE_DIRS`` | ||||
16 | # This has to be passed to target_include_directories() | ||||
17 | # | ||||
18 | # On Linux, the libraries and include directories are empty, | ||||
19 | # even though epoll_FOUND may be set to TRUE. This is because | ||||
20 | # no special includes or libraries are needed. On other systems | ||||
21 | # these may be needed to use epoll. | ||||
22 | | ||||
23 | #============================================================================= | ||||
24 | # Copyright 2019 Tobias C. Berner <tcberner@FreeBSD.org> | ||||
25 | # | ||||
26 | # Redistribution and use in source and binary forms, with or without | ||||
27 | # modification, are permitted provided that the following conditions | ||||
28 | # are met: | ||||
29 | # | ||||
30 | # 1. Redistributions of source code must retain the copyright | ||||
31 | # notice, this list of conditions and the following disclaimer. | ||||
32 | # 2. Redistributions in binary form must reproduce the copyright | ||||
33 | # notice, this list of conditions and the following disclaimer in the | ||||
34 | # documentation and/or other materials provided with the distribution. | ||||
35 | # | ||||
36 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | ||||
37 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | ||||
38 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||||
39 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | ||||
40 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||||
41 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
42 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
43 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
44 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | ||||
45 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
46 | #============================================================================= | ||||
47 | | ||||
48 | find_path(epoll_INCLUDE_DIRS sys/epoll.h PATH_SUFFIXES libepoll-shim) | ||||
49 | | ||||
50 | if(epoll_INCLUDE_DIRS) | ||||
51 | # On Linux there is no library to link against, on the BSDs there is. | ||||
52 | # On the BSD's, epoll is implemented through a library, libepoll-shim. | ||||
53 | if( CMAKE_SYSTEM_NAME MATCHES "Linux") | ||||
54 | set(epoll_FOUND TRUE) | ||||
55 | set(epoll_LIBRARIES "") | ||||
56 | set(epoll_INCLUDE_DIRS "") | ||||
57 | else() | ||||
58 | find_library(epoll_LIBRARIES NAMES epoll-shim) | ||||
59 | include(FindPackageHandleStandardArgs) | ||||
60 | find_package_handle_standard_args(epoll | ||||
61 | FOUND_VAR | ||||
62 | epoll_FOUND | ||||
63 | REQUIRED_VARS | ||||
64 | epoll_LIBRARIES | ||||
65 | epoll_INCLUDE_DIRS | ||||
66 | ) | ||||
67 | mark_as_advanced(epoll_LIBRARIES epoll_INCLUDE_DIRS) | ||||
68 | include(FeatureSummary) | ||||
69 | set_package_properties(epoll PROPERTIES | ||||
70 | URL "https://github.com/FreeBSDDesktop/epoll-shim" | ||||
71 | DESCRIPTION "small epoll implementation using kqueue" | ||||
72 | ) | ||||
73 | endif() | ||||
74 | else() | ||||
75 | set(epoll_FOUND FALSE) | ||||
76 | endif() | ||||
77 | | ||||
78 | mark_as_advanced(epoll_LIBRARIES epoll_INCLUDE_DIRS) |