Skip to content

Commit bf10eaf

Browse files
committed
Fix issues in test cmake, so that it uses the local libkqueue and headers
1 parent 7d314cf commit bf10eaf

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

test/CMakeLists.txt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
4242
add_executable(libkqueue-test ${LIBKQUEUE_TEST_SOURCES})
4343
target_include_directories(libkqueue-test
4444
PRIVATE
45-
"${CMAKE_SOURCE_DIR}"
46-
"${CMAKE_SOURCE_DIR}/include")
45+
"${CMAKE_SOURCE_DIR}"
46+
"${CMAKE_SOURCE_DIR}/include")
4747
if(WIN32)
4848
target_compile_definitions(libkqueue-test
4949
PRIVATE
@@ -61,9 +61,25 @@ endif()
6161
# Don't link against -lkqueue on OSX and FreeBSD
6262
#
6363
if(NOT "${CMAKE_SYSTEM_NAME}" MATCHES "(Darwin|FreeBSD)")
64+
# Prefer -pthread on POSIX
65+
set(THREADS_PREFER_PTHREAD_FLAG ON)
66+
find_package(Threads REQUIRED)
67+
68+
# Use our locally built libkqueue
69+
find_library(KQUEUE_LIB
70+
NAMES kqueue
71+
PATHS ${PROJECT_SOURCE_DIR}/../
72+
NO_DEFAULT_PATH
73+
REQUIRED
74+
)
75+
76+
# Allow test program to find libkqueue headers
77+
target_include_directories(libkqueue-test PRIVATE
78+
${PROJECT_SOURCE_DIR}/../include)
79+
6480
target_link_libraries(libkqueue-test
6581
PRIVATE
66-
kqueue
82+
${KQUEUE_LIB}
6783
Threads::Threads)
6884
endif()
6985

0 commit comments

Comments
 (0)