-
Notifications
You must be signed in to change notification settings - Fork 9
/
CMakeLists.txt
66 lines (55 loc) · 1.98 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
cmake_minimum_required(VERSION 3.22)
if (EXISTS ${CMAKE_BINARY_DIR}/local.cmake)
include(${CMAKE_BINARY_DIR}/local.cmake)
endif ()
project(netlib)
find_package(PkgConfig REQUIRED)
pkg_check_modules(CMOCKA REQUIRED cmocka)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
pkg_check_modules(URING REQUIRED liburing)
endif ()
pkg_check_modules(OPENSSL openssl)
enable_testing()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
add_library(coroio
coroio/socket.cpp
coroio/sockutils.cpp
coroio/poll.cpp
coroio/select.cpp
coroio/epoll.cpp
coroio/uring.cpp
coroio/kqueue.cpp
coroio/resolver.cpp
coroio/ssl.cpp
)
target_include_directories(coroio PUBLIC ${URING_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIRS})
target_link_directories(coroio PUBLIC ${URING_LIBRARY_DIRS} ${OPENSSL_LIBRARY_DIRS})
target_link_libraries(coroio PUBLIC ${URING_LIBRARIES} ${OPENSSL_LIBRARIES})
if(MSVC)
target_compile_options(coroio PRIVATE /W4 /WX)
else()
target_compile_options(coroio PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
macro(target name source)
add_executable(${name} ${source})
target_link_libraries(${name} coroio)
endmacro()
macro(ut name source)
add_executable(ut_${name} ${source})
target_include_directories(ut_${name} PRIVATE ${CMOCKA_INCLUDE_DIRS})
target_link_directories(ut_${name} PRIVATE ${CMOCKA_LIBRARY_DIRS})
target_link_libraries(ut_${name} PRIVATE coroio ${CMOCKA_LIBRARIES})
add_test(NAME ${name} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/ut_${name})
set_tests_properties(${name} PROPERTIES ENVIRONMENT "CMOCKA_MESSAGE_OUTPUT=xml;CMOCKA_XML_FILE=${name}.xml")
endmacro()
target(timers examples/timers.cpp)
target(echotest examples/echotest.cpp)
target(echoserver examples/echoserver.cpp)
target(echoclient examples/echoclient.cpp)
target(sslechoclient examples/sslechoclient.cpp)
target(sslechoserver examples/sslechoserver.cpp)
target(resolver examples/resolver.cpp)
target(bench examples/bench.cpp)
ut(tests tests/tests.cpp)