-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
205 lines (171 loc) · 4.55 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
cmake_minimum_required(VERSION 3.3)
project(pp)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON "export symbols")
set(PP_BUILD_INSTALL FALSE CACHE BOOL "install library or not")
set(PP_DISABLED_TEST FALSE CACHE BOOL "build uint test or not")
set(PP_DISABLE_EXAMPLE FALSE CACHE BOOL "build example or not")
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(IS_WIN TRUE)
add_definitions(-DWIN32)
endif()
# add_compile_options(-std=c++11)
if(NOT PP_DISABLED_TEST)
enable_testing()
endif()
include_directories(include)
include_directories(src/system)
include_directories(src/time)
include_directories(src/errors)
# auto create libcurl dir in ${PROJECT_BINARY_DIR}
#link_directories(${PROJECT_BINARY_DIR}/libcurl/lib)
#include_directories(${PROJECT_BINARY_DIR}/libcurl/include)
#add_subdirectory(src)
if(IS_WIN)
add_definitions(-DWIN32_LEAN_AND_MEAN )
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS )
endif()
include_directories(
src/io
src/net
)
####strings
set(strings-src-list
src/strings/strings.cpp
)
####io
set(io-src-list
src/io/io.cpp
# src/io/io_thread_local_storage.h
src/io/io_event_loop.cpp
src/io/io_event_fd.cpp
)
if(IS_WIN)
set(io-src-list
${io-src-list}
# src/io/windows/thread_local_storage_win.cpp
src/io/windows/io_win_iocp_event_fd.cpp
src/io/windows/io_win_iocp_event_fd.h
src/io/windows/io_win_iocp_poller.cpp
src/io/windows/io_win_iocp_poller.h
#src/io/windows/io_win_overlapped_pipe.cpp
#src/io/windows/io_win_overlapped_pipe.h
#src/io/windows/io_win_iocp_pipe_event_fd.cpp
#src/io/windows/io_win_iocp_pipe_event_fd.h
#src/io/windows/io_win_iocp_tcp_event_fd.cpp
#src/io/windows/io_win_iocp_tcp_event_fd.h
)
endif()
include_directories(http-parser)
####net
set(net-src-list
src/net/tcp_server.cpp
src/net/tcp_client.cpp
src/net/http/http_client.cpp
src/net/http/http_conn_ctx.cpp
src/net/http/http_conn_ctx.h
http-parser/http_parser.c
http-parser/http_parser.h
)
if(IS_WIN)
set(net-src-list
${net-src-list}
src/net/windows/net_win_tcp_conn.cpp
src/net/windows/net_win_iocp_tcp_accpeter.cpp
src/net/windows/net_win_iocp_tcp_accpeter.h
src/net/windows/net_win_iocp_tcp_connector.cpp
src/net/windows/net_win_socket.cpp
)
endif()
###system
if(IS_WIN)
set(system-src-list
src/system/windows/sys_win_condition.cpp
src/system/windows/sys_win_mutex.cpp
src/system/windows/sys_win_thread_call_once.cpp
src/system/windows/sys_win_thread.cpp
src/system/windows/sys_win_thread_local_storage.cpp
)
endif()
###fmt
set(fmt-src-list
src/fmt/format.cpp
)
###bytes
set(bytes-src-list
src/bytes/buffer.cpp
)
###time
set(time-src-list
src/time/time.cpp
src/time/timer.cpp
src/time/timer_queue.cpp
)
if(IS_WIN)
set(time-src-list
${time-src-list}
src/time/time_win.cpp
)
endif()
###errors
set(errors-src-list
src/errors/errors.cpp
)
if(IS_WIN)
set(errors-src-list
${errors-src-list}
src/errors/windows/errors_windows.cpp
)
endif()
add_library(pp
${strings-src-list}
${io-src-list}
${net-src-list}
${fmt-src-list}
${system-src-list}
${bytes-src-list}
${time-src-list}
${errors-src-list})
target_link_libraries(pp PUBLIC ws2_32)
if(WIN32)
target_compile_definitions(pp PRIVATE _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS)
endif()
if(NOT PP_DISABLED_TEST)
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
add_subdirectory(googletest)
if(CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories("${gtest_SOURCE_DIR}/include")
endif()
include(GoogleTest)
add_subdirectory(test)
endif()
if(NOT PP_DISABLE_EXAMPLES)
add_subdirectory(example)
endif()
if(PP_BUILD_INSTALL)
if(CMAKE_SIZEOF_VOID_P STREQUAL 4)
set(platform x86)
else()
set(platform x64)
endif()
install(TARGETS pp
CONFIGURATIONS RelWithDebInfo
RUNTIME DESTINATION bin/static.${platform}.RelWithDebInfo
ARCHIVE DESTINATION lib/static.${platform}.RelWithDebInfo
LIBRARY DESTINATION lib/static.${platform}.RelWithDebInfo
)
install(TARGETS pp
CONFIGURATIONS Release
RUNTIME DESTINATION bin/static.${platform}.Release
ARCHIVE DESTINATION lib/static.${platform}.Release
LIBRARY DESTINATION lib/static.${platform}.Release
)
install(TARGETS pp
CONFIGURATIONS Debug
RUNTIME DESTINATION bin/static.${platform}.Debug
ARCHIVE DESTINATION lib/static.${platform}.Debug
LIBRARY DESTINATION lib/static.${platform}.Debug
)
install(DIRECTORY include/
DESTINATION include
)
endif()