summaryrefslogtreecommitdiffstats
path: root/Utilities/cmlibuv/CMakeLists.txt
blob: a62c516ef00d9c537289d55cf8a09973ac537975 (plain)
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
project(libuv C)

# Disable warnings to avoid changing 3rd party code.
if(CMAKE_C_COMPILER_ID MATCHES
    "^(GNU|Clang|AppleClang|XL|VisualAge|SunPro|MIPSpro|HP|Intel)$")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -w")
elseif(CMAKE_C_COMPILER_ID STREQUAL "PathScale")
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -woffall")
endif()

find_package(Threads)

set(uv_libraries ${CMAKE_THREAD_LIBS_INIT})
set(uv_includes include src)
set(uv_headers
  include/uv.h
  include/uv/errno.h
  include/uv/threadpool.h
  include/uv/version.h
  )
set(uv_sources
  src/fs-poll.c
  src/heap-inl.h
  src/idna.c
  src/idna.h
  src/inet.c
  src/queue.h
  src/strscpy.c
  src/strscpy.h
  src/threadpool.c
  src/timer.c
  src/uv-common.c
  src/uv-common.h
  src/uv-data-getter-setters.c
  src/version.c
  )
if(WIN32)
  list(APPEND uv_libraries
    ws2_32
    psapi
    iphlpapi
    shell32
    userenv
    )
  list(APPEND uv_includes
    src/win
    )
  list(APPEND uv_defines
    WIN32_LEAN_AND_MEAN
    _WIN32_WINNT=0x0600
    )
  list(APPEND uv_headers
    include/uv/win.h
    include/tree.h
    )
  list(APPEND uv_sources
    src/win/async.c
    src/win/atomicops-inl.h
    src/win/core.c
    src/win/detect-wakeup.c
    src/win/dl.c
    src/win/error.c
    src/win/fs-event.c
    src/win/fs.c
    src/win/getaddrinfo.c
    src/win/getnameinfo.c
    src/win/handle.c
    src/win/handle-inl.h
    src/win/internal.h
    src/win/loop-watcher.c
    src/win/pipe.c
    src/win/poll.c
    src/win/process-stdio.c
    src/win/process.c
    src/win/req-inl.h
    src/win/signal.c
    src/win/snprintf.c
    src/win/stream.c
    src/win/stream-inl.h
    src/win/tcp.c
    src/win/thread.c
    src/win/tty.c
    src/win/udp.c
    src/win/util.c
    src/win/winapi.c
    src/win/winapi.h
    src/win/winsock.c
    src/win/winsock.h
    )
else()
  list(APPEND uv_includes
    src/unix
    )
  list(APPEND uv_headers
    include/uv/unix.h
    )
  list(APPEND uv_sources
    src/unix/async.c
    src/unix/atomic-ops.h
    src/unix/core.c
    src/unix/dl.c
    src/unix/fs.c
    src/unix/getaddrinfo.c
    src/unix/getnameinfo.c
    src/unix/internal.h
    src/unix/loop-watcher.c
    src/unix/loop.c
    src/unix/pipe.c
    src/unix/poll.c
    src/unix/process.c
    src/unix/signal.c
    src/unix/spinlock.h
    src/unix/stream.c
    src/unix/tcp.c
    src/unix/thread.c
    src/unix/tty.c
    src/unix/udp.c
    )
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
  list(APPEND uv_libraries
    perfstat
    )
  list(APPEND uv_headers
    include/uv/aix.h
    )
  list(APPEND uv_defines
    _ALL_SOURCE
    _XOPEN_SOURCE=500
    _LINUX_SOURCE_COMPAT
    _THREAD_SAFE
    )
  list(APPEND uv_sources
    src/unix/aix.c
    src/unix/aix-common.c
    )
endif()

if(CMAKE_SYSTEM_NAME MATCHES "CYGWIN")
  list(APPEND uv_libraries
    )
  list(APPEND uv_headers
    include/uv/posix.h
    )
  list(APPEND uv_defines
    )
  list(APPEND uv_sources
    src/unix/cygwin.c
    src/unix/bsd-ifaddrs.c
    src/unix/no-fsevents.c
    src/unix/no-proctitle.c
    src/unix/posix-hrtime.c
    src/unix/posix-poll.c
    src/unix/procfs-exepath.c
    src/unix/sysinfo-loadavg.c
    src/unix/sysinfo-memory.c
    )
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  list(APPEND uv_headers
    include/uv/darwin.h
    )
  list(APPEND uv_defines
    _DARWIN_USE_64_BIT_INODE=1
    _DARWIN_UNLIMITED_SELECT=1
    )
  list(APPEND uv_sources
    src/unix/bsd-ifaddrs.c
    src/unix/darwin.c
    src/unix/darwin-proctitle.c
    src/unix/fsevents.c
    src/unix/kqueue.c
    src/unix/proctitle.c
    )
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  list(APPEND uv_libraries dl rt)
  list(APPEND uv_headers
    include/uv/linux.h
    )
  list(APPEND uv_defines _GNU_SOURCE)
  list(APPEND uv_sources
    src/unix/linux-core.c
    src/unix/linux-inotify.c
    src/unix/linux-syscalls.c
    src/unix/linux-syscalls.h
    src/unix/procfs-exepath.c
    src/unix/proctitle.c
    src/unix/sysinfo-loadavg.c
    src/unix/sysinfo-memory.c
    )
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
  list(APPEND uv_libraries
    kvm
    )
  list(APPEND uv_headers
    include/uv/bsd.h
    )
  list(APPEND uv_sources
    src/unix/bsd-ifaddrs.c
    src/unix/bsd-proctitle.c
    src/unix/freebsd.c
    src/unix/kqueue.c
    src/unix/posix-hrtime.c
    )
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "kFreeBSD")
  list(APPEND uv_libraries
    freebsd-glue
    kvm
    )
  list(APPEND uv_headers
    include/uv/bsd.h
    )
  list(APPEND uv_sources
    src/unix/bsd-ifaddrs.c
    src/unix/bsd-proctitle.c
    src/unix/freebsd.c
    src/unix/kqueue.c
    src/unix/posix-hrtime.c
    )
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
  list(APPEND uv_libraries
    kvm
    )
  list(APPEND uv_headers
    include/uv/bsd.h
    )
  list(APPEND uv_sources
    src/unix/bsd-ifaddrs.c
    src/unix/bsd-proctitle.c
    src/unix/netbsd.c
    src/unix/kqueue.c
    src/unix/posix-hrtime.c
    )
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
  list(APPEND uv_libraries
    kvm
    )
  list(APPEND uv_headers
    include/uv/bsd.h
    )
  list(APPEND uv_sources
    src/unix/bsd-ifaddrs.c
    src/unix/bsd-proctitle.c
    src/unix/openbsd.c
    src/unix/kqueue.c
    src/unix/posix-hrtime.c
    )
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  list(APPEND uv_libraries
    kstat
    nsl
    sendfile
    socket
    rt
    )
  list(APPEND uv_headers
    include/uv/sunos.h
    )
  list(APPEND uv_defines
    __EXTENSIONS__
    )
  if(CMAKE_SYSTEM_VERSION STREQUAL "5.10")
    set(CMAKE_C_STANDARD 90)
    if(CMAKE_VERSION VERSION_LESS 3.8.20170504 AND CMAKE_C_COMPILER_ID STREQUAL "SunPro" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.14)
      # The running version of CMake does not know how to add this flag.
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c90")
    endif()
    list(APPEND uv_defines
      _XOPEN_SOURCE=500
      )
  else()
    if(NOT CMAKE_C_STANDARD OR CMAKE_C_STANDARD EQUAL 90)
      set(CMAKE_C_STANDARD 11)
    endif()
    if(CMAKE_VERSION VERSION_LESS 3.8.20170505 AND CMAKE_C_COMPILER_ID STREQUAL "SunPro" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 5.14)
      # The running version of CMake does not know how to add this flag.
      set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -xc99")
    endif()
    list(APPEND uv_defines
      _XOPEN_SOURCE=600
      )
  endif()
  list(APPEND uv_sources
    src/unix/no-proctitle.c
    src/unix/sunos.c
    )
endif()

include_directories(
  ${uv_includes}
  ${KWSYS_HEADER_ROOT}
  )
add_library(cmlibuv STATIC ${uv_sources})
target_link_libraries(cmlibuv ${uv_libraries})
set_property(TARGET cmlibuv PROPERTY COMPILE_DEFINITIONS ${uv_defines})

install(FILES LICENSE DESTINATION ${CMAKE_DOC_DIR}/cmlibuv)