-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
133 lines (114 loc) · 3.19 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
cmake_minimum_required(VERSION 3.17)
project(asyncio)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
set(ASYNCIO_VERSION 1.0.4)
option(BUILD_SAMPLES "Build asyncio samples" ON)
option(BUILD_SHARED_LIBS "Build using shared libraries" OFF)
if (BUILD_SHARED_LIBS AND MSVC)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif ()
include(CTest)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
find_package(OpenSSL REQUIRED)
find_package(zero CONFIG REQUIRED)
find_package(CURL CONFIG REQUIRED)
find_package(libuv CONFIG REQUIRED)
find_package(nlohmann_json CONFIG REQUIRED)
add_library(
asyncio
src/uv.cpp
src/io.cpp
src/fs.cpp
src/time.cpp
src/poll.cpp
src/pipe.cpp
src/thread.cpp
src/signal.cpp
src/stream.cpp
src/buffer.cpp
src/channel.cpp
src/process.cpp
src/task.cpp
src/event_loop.cpp
src/net/net.cpp
src/net/dns.cpp
src/net/tls.cpp
src/net/dgram.cpp
src/net/stream.cpp
src/http/url.cpp
src/http/request.cpp
src/http/websocket.cpp
src/sync/mutex.cpp
src/sync/event.cpp
src/sync/condition.cpp
)
if (WIN32)
target_compile_definitions(asyncio PUBLIC NOMINMAX)
endif ()
target_include_directories(
asyncio
PUBLIC
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
)
target_link_libraries(
asyncio
PRIVATE
$<$<PLATFORM_ID:Windows>:Crypt32>
PUBLIC
zero::zero
OpenSSL::SSL
OpenSSL::Crypto
CURL::libcurl
nlohmann_json::nlohmann_json
$<IF:$<TARGET_EXISTS:libuv::uv_a>,libuv::uv_a,libuv::uv>
)
add_library(asyncio-main STATIC src/main.cpp)
target_link_libraries(asyncio-main PUBLIC asyncio)
install(
DIRECTORY
include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
${EXCLUDE_HEADERS}
)
install(
TARGETS asyncio
EXPORT ${PROJECT_NAME}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(
TARGETS asyncio-main
EXPORT ${PROJECT_NAME}Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
EXPORT ${PROJECT_NAME}Targets
NAMESPACE asyncio::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
configure_package_config_file(
cmake/${PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
VERSION ${ASYNCIO_VERSION}
COMPATIBILITY SameMajorVersion
)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
if (BUILD_SAMPLES)
add_subdirectory(sample)
endif ()
if (BUILD_TESTING)
add_subdirectory(test)
endif ()