Skip to content

Commit 98bf8ce

Browse files
committed
Trying to fix build on osx and bsd.
1 parent 4e7dcb2 commit 98bf8ce

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

CMakeLists.txt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@ file(GLOB SOURCES Lib/*.c)
4444
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
4545
set(SOURCES ${SOURCES} Lib/poll_plugins/epoll_priv.c)
4646
else()
47-
find_package(Kqueue REQUIRED)
47+
include(CheckFunctionExists)
48+
check_function_exists(kqueue KQUEUE_IN_LIBC)
49+
if(NOT KQUEUE_IN_LIBC)
50+
find_package(Kqueue REQUIRED)
51+
else()
52+
set(KQUEUE_LIBRARIES "")
53+
endif()
4854
set(SOURCES ${SOURCES} Lib/poll_plugins/kqueue_priv.c)
4955
endif()
5056

@@ -68,8 +74,7 @@ set_target_properties(
6874
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wtype-limits -Wstrict-overflow -fno-strict-aliasing -Wformat -Wformat-security")
6975
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -fvisibility=hidden")
7076

71-
# KQUEUE_INCLUDE_DIRS will be empty where native epoll/kqueue are supported
72-
target_include_directories(${PROJECT_NAME} PRIVATE Lib/ Lib/public/module/ ${KQUEUE_INCLUDE_DIRS})
77+
target_include_directories(${PROJECT_NAME} PRIVATE Lib/ Lib/public/module/)
7378

7479
# KQUEUE_LIBRARIES will be empty where native epoll/kqueue are supported
7580
target_link_libraries(${PROJECT_NAME} ${KQUEUE_LIBRARIES})

cmake/FindKqueue.cmake

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
include (FindPackageHandleStandardArgs)
2-
include (CheckFunctionExists)
32

43
find_package(Threads)
54

65
find_path(KQUEUE_INCLUDE_DIRS sys/event.h PATH_SUFFIXES kqueue)
76

8-
check_function_exists(KQUEUE_IN_LIBC kqueue)
9-
10-
if (KQUEUE_IN_LIBC)
11-
set (_KQUEUE_LIB " ")
12-
else ()
13-
find_library(_KQUEUE_LIB "kqueue")
14-
mark_as_advanced(_KQUEUE_LIB)
15-
endif ()
16-
17-
set (KQUEUE_LIBRARIES "${_KQUEUE_LIB}" ${CMAKE_THREAD_LIBS_INIT}
18-
CACHE STRING "Libraries to link libkqueue")
7+
find_library(_KQUEUE_LIB "kqueue")
8+
mark_as_advanced(_KQUEUE_LIB)
9+
set(KQUEUE_LIBRARIES "${_KQUEUE_LIB}" ${CMAKE_THREAD_LIBS_INIT}
10+
CACHE STRING "Libraries to link libkqueue")
1911

2012
find_package_handle_standard_args(kqueue DEFAULT_MSG
21-
KQUEUE_LIBRARIES
22-
KQUEUE_INCLUDE_DIRS
23-
THREADS_FOUND
13+
KQUEUE_LIBRARIES
14+
KQUEUE_INCLUDE_DIRS
15+
THREADS_FOUND
2416
)
17+

0 commit comments

Comments
 (0)