Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Kitware
GitHub Repository: Kitware/CMake
Path: blob/master/Utilities/cmlibuv/CMakeLists.txt
3148 views
1
project(libuv C)
2
3
# Disable warnings to avoid changing 3rd party code.
4
if(CMAKE_C_COMPILER_ID MATCHES
5
"^(GNU|LCC|Clang|AppleClang|IBMClang|XLClang|XL|VisualAge|SunPro|HP|Intel|IntelLLVM|NVHPC)$")
6
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
7
elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
8
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
9
endif()
10
11
find_package(Threads)
12
13
set(uv_libraries ${CMAKE_THREAD_LIBS_INIT})
14
set(uv_includes include src)
15
set(uv_headers
16
include/uv.h
17
include/uv/errno.h
18
include/uv/threadpool.h
19
include/uv/version.h
20
)
21
set(uv_sources
22
src/fs-poll.c
23
src/heap-inl.h
24
src/idna.c
25
src/idna.h
26
src/inet.c
27
src/queue.h
28
src/strscpy.c
29
src/strscpy.h
30
src/strtok.c
31
src/strtok.h
32
src/threadpool.c
33
src/timer.c
34
src/uv-common.c
35
src/uv-common.h
36
src/uv-data-getter-setters.c
37
src/version.c
38
)
39
if(WIN32)
40
list(APPEND uv_libraries
41
ws2_32
42
psapi
43
iphlpapi
44
shell32
45
userenv
46
)
47
list(APPEND uv_includes
48
src/win
49
)
50
list(APPEND uv_defines
51
WIN32_LEAN_AND_MEAN
52
_WIN32_WINNT=0x0600
53
)
54
list(APPEND uv_headers
55
include/uv/win.h
56
include/tree.h
57
)
58
list(APPEND uv_sources
59
src/win/async.c
60
src/win/atomicops-inl.h
61
src/win/core.c
62
src/win/detect-wakeup.c
63
src/win/dl.c
64
src/win/error.c
65
src/win/fs-event.c
66
src/win/fs.c
67
src/win/getaddrinfo.c
68
src/win/getnameinfo.c
69
src/win/handle.c
70
src/win/handle-inl.h
71
src/win/internal.h
72
src/win/loop-watcher.c
73
src/win/pipe.c
74
src/win/poll.c
75
src/win/process-stdio.c
76
src/win/process.c
77
src/win/req-inl.h
78
src/win/signal.c
79
src/win/snprintf.c
80
src/win/stream.c
81
src/win/stream-inl.h
82
src/win/tcp.c
83
src/win/thread.c
84
src/win/tty.c
85
src/win/udp.c
86
src/win/util.c
87
src/win/winapi.c
88
src/win/winapi.h
89
src/win/winsock.c
90
src/win/winsock.h
91
)
92
else()
93
list(APPEND uv_includes
94
src/unix
95
)
96
list(APPEND uv_headers
97
include/uv/unix.h
98
)
99
list(APPEND uv_sources
100
src/unix/async.c
101
src/unix/atomic-ops.h
102
src/unix/core.c
103
src/unix/dl.c
104
src/unix/fs.c
105
src/unix/getaddrinfo.c
106
src/unix/getnameinfo.c
107
src/unix/internal.h
108
src/unix/loop-watcher.c
109
src/unix/loop.c
110
src/unix/pipe.c
111
src/unix/poll.c
112
src/unix/process.c
113
src/unix/signal.c
114
src/unix/spinlock.h
115
src/unix/stream.c
116
src/unix/tcp.c
117
src/unix/thread.c
118
src/unix/tty.c
119
src/unix/udp.c
120
)
121
endif()
122
123
if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
124
list(APPEND uv_libraries
125
perfstat
126
)
127
list(APPEND uv_headers
128
include/uv/aix.h
129
)
130
list(APPEND uv_defines
131
_ALL_SOURCE
132
_XOPEN_SOURCE=500
133
_LINUX_SOURCE_COMPAT
134
_THREAD_SAFE
135
)
136
list(APPEND uv_sources
137
src/unix/aix.c
138
src/unix/aix-common.c
139
)
140
endif()
141
142
if(CMAKE_SYSTEM_NAME STREQUAL "OS400")
143
list(APPEND uv_headers
144
include/uv/posix.h
145
)
146
list(APPEND uv_defines
147
_ALL_SOURCE
148
_XOPEN_SOURCE=500
149
_LINUX_SOURCE_COMPAT
150
_THREAD_SAFE
151
)
152
list(APPEND uv_sources
153
src/unix/aix-common.c
154
src/unix/ibmi.c
155
src/unix/posix-poll.c
156
src/unix/no-fsevents.c
157
src/unix/no-proctitle.c
158
)
159
endif()
160
161
if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN" OR CMAKE_SYSTEM_NAME MATCHES "MSYS")
162
list(APPEND uv_libraries
163
)
164
list(APPEND uv_headers
165
include/uv/posix.h
166
)
167
list(APPEND uv_defines
168
_GNU_SOURCE
169
)
170
list(APPEND uv_sources
171
src/unix/cygwin.c
172
src/unix/bsd-ifaddrs.c
173
src/unix/no-fsevents.c
174
src/unix/no-proctitle.c
175
src/unix/posix-hrtime.c
176
src/unix/posix-poll.c
177
src/unix/procfs-exepath.c
178
src/unix/sysinfo-loadavg.c
179
src/unix/sysinfo-memory.c
180
)
181
endif()
182
183
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
184
list(APPEND uv_headers
185
include/uv/darwin.h
186
)
187
list(APPEND uv_defines
188
_DARWIN_USE_64_BIT_INODE=1
189
_DARWIN_UNLIMITED_SELECT=1
190
)
191
list(APPEND uv_sources
192
src/unix/bsd-ifaddrs.c
193
src/unix/darwin.c
194
src/unix/darwin-proctitle.c
195
src/unix/fsevents.c
196
src/unix/kqueue.c
197
src/unix/proctitle.c
198
)
199
endif()
200
201
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
202
list(APPEND uv_libraries dl rt)
203
list(APPEND uv_headers
204
include/uv/linux.h
205
)
206
list(APPEND uv_defines _GNU_SOURCE)
207
list(APPEND uv_sources
208
src/unix/epoll.c
209
src/unix/linux-core.c
210
src/unix/linux-inotify.c
211
src/unix/linux-syscalls.c
212
src/unix/linux-syscalls.h
213
src/unix/procfs-exepath.c
214
src/unix/proctitle.c
215
src/unix/sysinfo-loadavg.c
216
src/unix/sysinfo-memory.c
217
)
218
endif()
219
220
if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
221
list(APPEND uv_libraries
222
)
223
list(APPEND uv_headers
224
include/uv/bsd.h
225
)
226
list(APPEND uv_sources
227
src/unix/bsd-ifaddrs.c
228
src/unix/bsd-proctitle.c
229
src/unix/freebsd.c
230
src/unix/kqueue.c
231
src/unix/posix-hrtime.c
232
)
233
endif()
234
235
if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
236
list(APPEND uv_libraries
237
kvm
238
)
239
list(APPEND uv_headers
240
include/uv/bsd.h
241
)
242
list(APPEND uv_sources
243
src/unix/bsd-ifaddrs.c
244
src/unix/bsd-proctitle.c
245
src/unix/netbsd.c
246
src/unix/kqueue.c
247
src/unix/posix-hrtime.c
248
)
249
endif()
250
251
if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
252
list(APPEND uv_libraries
253
)
254
list(APPEND uv_headers
255
include/uv/bsd.h
256
)
257
list(APPEND uv_sources
258
src/unix/bsd-ifaddrs.c
259
src/unix/bsd-proctitle.c
260
src/unix/openbsd.c
261
src/unix/kqueue.c
262
src/unix/posix-hrtime.c
263
)
264
endif()
265
266
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
267
list(APPEND uv_libraries
268
kstat
269
nsl
270
sendfile
271
socket
272
rt
273
)
274
list(APPEND uv_headers
275
include/uv/sunos.h
276
)
277
list(APPEND uv_defines
278
__EXTENSIONS__
279
_XOPEN_SOURCE=600
280
)
281
if(NOT CMAKE_C_STANDARD OR CMAKE_C_STANDARD EQUAL 90)
282
set(CMAKE_C_STANDARD 11)
283
endif()
284
if(CMAKE_SYSTEM_VERSION STREQUAL "5.10")
285
list(APPEND uv_defines SUNOS_NO_IFADDRS)
286
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i386|x86_64)$")
287
list(APPEND uv_defines CMAKE_NO_MKDTEMP)
288
endif()
289
endif()
290
list(APPEND uv_sources
291
src/unix/no-proctitle.c
292
src/unix/sunos.c
293
)
294
endif()
295
296
if(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
297
list(APPEND uv_libraries
298
rt
299
)
300
list(APPEND uv_headers
301
include/uv/posix.h
302
)
303
list(APPEND uv_defines
304
_XOPEN_SOURCE_EXTENDED
305
CMAKE_NO_MKDTEMP
306
)
307
list(APPEND uv_sources
308
src/unix/hpux.c
309
src/unix/no-fsevents.c
310
src/unix/posix-poll.c
311
)
312
endif()
313
314
if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
315
list(APPEND uv_headers
316
include/uv/posix.h
317
)
318
list(APPEND uv_defines
319
_XOPEN_SOURCE=700
320
)
321
list(APPEND uv_sources
322
src/unix/posix-hrtime.c
323
src/unix/posix-poll.c
324
src/unix/no-fsevents.c
325
src/unix/no-proctitle.c
326
)
327
list(APPEND uv_libraries
328
socket
329
)
330
endif()
331
332
include_directories(
333
${uv_includes}
334
${KWSYS_HEADER_ROOT}
335
)
336
add_library(cmlibuv STATIC ${uv_sources})
337
target_link_libraries(cmlibuv ${uv_libraries})
338
set_property(TARGET cmlibuv PROPERTY COMPILE_DEFINITIONS ${uv_defines})
339
340
if(WIN32 AND CMake_BUILD_PCH)
341
target_precompile_headers(cmlibuv PRIVATE "include/uv.h" "src/win/internal.h")
342
endif()
343
344
install(FILES LICENSE DESTINATION ${CMAKE_DOC_DIR}/cmlibuv)
345
346