• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1cmake_minimum_required(VERSION 3.4)
2project(libuv LANGUAGES C)
3
4cmake_policy(SET CMP0057 NEW) # Enable IN_LIST operator
5cmake_policy(SET CMP0064 NEW) # Support if (TEST) operator
6
7list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
8
9include(CMakePackageConfigHelpers)
10include(CMakeDependentOption)
11include(CheckCCompilerFlag)
12include(GNUInstallDirs)
13include(CTest)
14
15set(CMAKE_C_VISIBILITY_PRESET hidden)
16set(CMAKE_C_STANDARD_REQUIRED ON)
17set(CMAKE_C_EXTENSIONS ON)
18set(CMAKE_C_STANDARD 90)
19
20cmake_dependent_option(LIBUV_BUILD_TESTS
21  "Build the unit tests when BUILD_TESTING is enabled and we are the root project" ON
22  "BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF)
23cmake_dependent_option(LIBUV_BUILD_BENCH
24  "Build the benchmarks when building unit tests and we are the root project" ON
25  "LIBUV_BUILD_TESTS" OFF)
26
27# Qemu Build
28option(QEMU "build for qemu" OFF)
29if(QEMU)
30  add_definitions(-D__QEMU__=1)
31endif()
32
33option(ASAN "Enable AddressSanitizer (ASan)" OFF)
34option(TSAN "Enable ThreadSanitizer (TSan)" OFF)
35
36if((ASAN OR TSAN) AND NOT (CMAKE_C_COMPILER_ID MATCHES "AppleClang|GNU|Clang"))
37  message(SEND_ERROR "Sanitizer support requires clang or gcc. Try again with -DCMAKE_C_COMPILER.")
38endif()
39
40if(ASAN)
41  add_definitions(-D__ASAN__=1)
42  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
43  set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
44  set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address")
45endif()
46
47if(TSAN)
48  add_definitions(-D__TSAN__=1)
49  set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-omit-frame-pointer -fsanitize=thread")
50  set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=thread")
51  set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=thread")
52endif()
53
54# Compiler check
55string(CONCAT is-msvc $<OR:
56  $<C_COMPILER_ID:MSVC>,
57  $<STREQUAL:${CMAKE_C_COMPILER_FRONTEND_VARIANT},MSVC>
58>)
59
60check_c_compiler_flag(/W4 UV_LINT_W4)
61check_c_compiler_flag(/wd4100 UV_LINT_NO_UNUSED_PARAMETER_MSVC)
62check_c_compiler_flag(/wd4127 UV_LINT_NO_CONDITIONAL_CONSTANT_MSVC)
63check_c_compiler_flag(/wd4201 UV_LINT_NO_NONSTANDARD_MSVC)
64check_c_compiler_flag(/wd4206 UV_LINT_NO_NONSTANDARD_EMPTY_TU_MSVC)
65check_c_compiler_flag(/wd4210 UV_LINT_NO_NONSTANDARD_FILE_SCOPE_MSVC)
66check_c_compiler_flag(/wd4232 UV_LINT_NO_NONSTANDARD_NONSTATIC_DLIMPORT_MSVC)
67check_c_compiler_flag(/wd4456 UV_LINT_NO_HIDES_LOCAL)
68check_c_compiler_flag(/wd4457 UV_LINT_NO_HIDES_PARAM)
69check_c_compiler_flag(/wd4459 UV_LINT_NO_HIDES_GLOBAL)
70check_c_compiler_flag(/wd4706 UV_LINT_NO_CONDITIONAL_ASSIGNMENT_MSVC)
71check_c_compiler_flag(/wd4996 UV_LINT_NO_UNSAFE_MSVC)
72
73check_c_compiler_flag(-Wall UV_LINT_WALL) # DO NOT use this under MSVC
74
75# TODO: Place these into its own function
76check_c_compiler_flag(-Wno-unused-parameter UV_LINT_NO_UNUSED_PARAMETER)
77check_c_compiler_flag(-Wstrict-prototypes UV_LINT_STRICT_PROTOTYPES)
78check_c_compiler_flag(-Wextra UV_LINT_EXTRA)
79
80check_c_compiler_flag(/utf-8 UV_LINT_UTF8_MSVC)
81
82set(lint-no-unused-parameter $<$<BOOL:${UV_LINT_NO_UNUSED_PARAMETER}>:-Wno-unused-parameter>)
83set(lint-strict-prototypes $<$<BOOL:${UV_LINT_STRICT_PROTOTYPES}>:-Wstrict-prototypes>)
84set(lint-extra $<$<BOOL:${UV_LINT_EXTRA}>:-Wextra>)
85set(lint-w4 $<$<BOOL:${UV_LINT_W4}>:/W4>)
86set(lint-no-unused-parameter-msvc $<$<BOOL:${UV_LINT_NO_UNUSED_PARAMETER_MSVC}>:/wd4100>)
87set(lint-no-conditional-constant-msvc $<$<BOOL:${UV_LINT_NO_CONDITIONAL_CONSTANT_MSVC}>:/wd4127>)
88set(lint-no-nonstandard-msvc $<$<BOOL:${UV_LINT_NO_NONSTANDARD_MSVC}>:/wd4201>)
89set(lint-no-nonstandard-empty-tu-msvc $<$<BOOL:${UV_LINT_NO_NONSTANDARD_EMPTY_TU_MSVC}>:/wd4206>)
90set(lint-no-nonstandard-file-scope-msvc $<$<BOOL:${UV_LINT_NO_NONSTANDARD_FILE_SCOPE_MSVC}>:/wd4210>)
91set(lint-no-nonstandard-nonstatic-dlimport-msvc $<$<BOOL:${UV_LINT_NO_NONSTANDARD_NONSTATIC_DLIMPORT_MSVC}>:/wd4232>)
92set(lint-no-hides-local-msvc $<$<BOOL:${UV_LINT_NO_HIDES_LOCAL}>:/wd4456>)
93set(lint-no-hides-param-msvc $<$<BOOL:${UV_LINT_NO_HIDES_PARAM}>:/wd4457>)
94set(lint-no-hides-global-msvc $<$<BOOL:${UV_LINT_NO_HIDES_GLOBAL}>:/wd4459>)
95set(lint-no-conditional-assignment-msvc $<$<BOOL:${UV_LINT_NO_CONDITIONAL_ASSIGNMENT_MSVC}>:/wd4706>)
96set(lint-no-unsafe-msvc $<$<BOOL:${UV_LINT_NO_UNSAFE_MSVC}>:/wd4996>)
97# Unfortunately, this one is complicated because MSVC and clang-cl support -Wall
98# but using it is like calling -Weverything
99string(CONCAT lint-default $<
100  $<AND:$<BOOL:${UV_LINT_WALL}>,$<NOT:${is-msvc}>>:-Wall
101>)
102set(lint-utf8-msvc $<$<BOOL:${UV_LINT_UTF8_MSVC}>:/utf-8>)
103
104list(APPEND uv_cflags ${lint-strict-prototypes} ${lint-extra} ${lint-default} ${lint-w4})
105list(APPEND uv_cflags ${lint-no-unused-parameter})
106list(APPEND uv_cflags ${lint-no-unused-parameter-msvc})
107list(APPEND uv_cflags ${lint-no-conditional-constant-msvc})
108list(APPEND uv_cflags ${lint-no-nonstandard-msvc})
109list(APPEND uv_cflags ${lint-no-nonstandard-empty-tu-msvc})
110list(APPEND uv_cflags ${lint-no-nonstandard-file-scope-msvc})
111list(APPEND uv_cflags ${lint-no-nonstandard-nonstatic-dlimport-msvc})
112list(APPEND uv_cflags ${lint-no-hides-local-msvc})
113list(APPEND uv_cflags ${lint-no-hides-param-msvc})
114list(APPEND uv_cflags ${lint-no-hides-global-msvc})
115list(APPEND uv_cflags ${lint-no-conditional-assignment-msvc})
116list(APPEND uv_cflags ${lint-no-unsafe-msvc})
117list(APPEND uv_cflags ${lint-utf8-msvc} )
118
119check_c_compiler_flag(-fno-strict-aliasing UV_F_STRICT_ALIASING)
120list(APPEND uv_cflags $<$<BOOL:${UV_F_STRICT_ALIASING}>:-fno-strict-aliasing>)
121
122set(uv_sources
123    src/fs-poll.c
124    src/idna.c
125    src/inet.c
126    src/random.c
127    src/strscpy.c
128    src/strtok.c
129    src/threadpool.c
130    src/timer.c
131    src/uv-common.c
132    src/uv-data-getter-setters.c
133    src/version.c)
134
135if(WIN32)
136  list(APPEND uv_defines WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0602)
137  list(APPEND uv_libraries
138       psapi
139       user32
140       advapi32
141       iphlpapi
142       userenv
143       ws2_32)
144  list(APPEND uv_sources
145       src/win/async.c
146       src/win/core.c
147       src/win/detect-wakeup.c
148       src/win/dl.c
149       src/win/error.c
150       src/win/fs.c
151       src/win/fs-event.c
152       src/win/getaddrinfo.c
153       src/win/getnameinfo.c
154       src/win/handle.c
155       src/win/loop-watcher.c
156       src/win/pipe.c
157       src/win/thread.c
158       src/win/poll.c
159       src/win/process.c
160       src/win/process-stdio.c
161       src/win/signal.c
162       src/win/snprintf.c
163       src/win/stream.c
164       src/win/tcp.c
165       src/win/tty.c
166       src/win/udp.c
167       src/win/util.c
168       src/win/winapi.c
169       src/win/winsock.c)
170  list(APPEND uv_test_libraries ws2_32)
171  list(APPEND uv_test_sources src/win/snprintf.c test/runner-win.c)
172else()
173  list(APPEND uv_defines _FILE_OFFSET_BITS=64 _LARGEFILE_SOURCE)
174  if(NOT CMAKE_SYSTEM_NAME MATCHES "Android|OS390|QNX")
175    # TODO: This should be replaced with find_package(Threads) if possible
176    # Android has pthread as part of its c library, not as a separate
177    # libpthread.so.
178    list(APPEND uv_libraries pthread)
179  endif()
180  list(APPEND uv_sources
181       src/unix/async.c
182       src/unix/core.c
183       src/unix/dl.c
184       src/unix/fs.c
185       src/unix/getaddrinfo.c
186       src/unix/getnameinfo.c
187       src/unix/loop-watcher.c
188       src/unix/loop.c
189       src/unix/pipe.c
190       src/unix/poll.c
191       src/unix/process.c
192       src/unix/random-devurandom.c
193       src/unix/signal.c
194       src/unix/stream.c
195       src/unix/tcp.c
196       src/unix/thread.c
197       src/unix/tty.c
198       src/unix/udp.c)
199  list(APPEND uv_test_sources test/runner-unix.c)
200endif()
201
202if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
203  list(APPEND uv_defines
204       _ALL_SOURCE
205       _LINUX_SOURCE_COMPAT
206       _THREAD_SAFE
207       _XOPEN_SOURCE=500
208       HAVE_SYS_AHAFS_EVPRODS_H)
209  list(APPEND uv_libraries perfstat)
210  list(APPEND uv_sources
211       src/unix/aix.c
212       src/unix/aix-common.c)
213endif()
214
215if(CMAKE_SYSTEM_NAME STREQUAL "Android")
216  list(APPEND uv_defines _GNU_SOURCE)
217  list(APPEND uv_libraries dl)
218  list(APPEND uv_sources
219       src/unix/linux-core.c
220       src/unix/linux-inotify.c
221       src/unix/linux-syscalls.c
222       src/unix/procfs-exepath.c
223       src/unix/pthread-fixes.c
224       src/unix/random-getentropy.c
225       src/unix/random-getrandom.c
226       src/unix/random-sysctl-linux.c
227       src/unix/epoll.c)
228endif()
229
230if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Android|Linux")
231  list(APPEND uv_sources src/unix/proctitle.c)
232endif()
233
234if(CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD")
235  list(APPEND uv_sources src/unix/freebsd.c)
236endif()
237
238if(CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD")
239  list(APPEND uv_sources src/unix/posix-hrtime.c src/unix/bsd-proctitle.c)
240endif()
241
242if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD")
243  list(APPEND uv_sources src/unix/bsd-ifaddrs.c src/unix/kqueue.c)
244endif()
245
246if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
247  list(APPEND uv_sources src/unix/random-getrandom.c)
248endif()
249
250if(APPLE OR CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
251  list(APPEND uv_sources src/unix/random-getentropy.c)
252endif()
253
254if(APPLE)
255  list(APPEND uv_defines _DARWIN_UNLIMITED_SELECT=1 _DARWIN_USE_64_BIT_INODE=1)
256  list(APPEND uv_sources
257       src/unix/darwin-proctitle.c
258       src/unix/darwin.c
259       src/unix/fsevents.c)
260endif()
261
262if(CMAKE_SYSTEM_NAME STREQUAL "GNU")
263  list(APPEND uv_libraries dl)
264  list(APPEND uv_sources
265       src/unix/bsd-ifaddrs.c
266       src/unix/no-fsevents.c
267       src/unix/no-proctitle.c
268       src/unix/posix-hrtime.c
269       src/unix/posix-poll.c
270       src/unix/hurd.c)
271endif()
272
273if(CMAKE_SYSTEM_NAME STREQUAL "kFreeBSD")
274  list(APPEND uv_defines _GNU_SOURCE)
275  list(APPEND uv_libraries dl freebsd-glue)
276endif()
277
278if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
279  list(APPEND uv_defines _GNU_SOURCE _POSIX_C_SOURCE=200112)
280  list(APPEND uv_libraries dl rt)
281  list(APPEND uv_sources
282       src/unix/linux-core.c
283       src/unix/linux-inotify.c
284       src/unix/linux-syscalls.c
285       src/unix/procfs-exepath.c
286       src/unix/random-getrandom.c
287       src/unix/random-sysctl-linux.c
288       src/unix/epoll.c)
289endif()
290
291if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
292  list(APPEND uv_sources src/unix/netbsd.c)
293  list(APPEND uv_libraries kvm)
294endif()
295
296if(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
297  list(APPEND uv_sources src/unix/openbsd.c)
298endif()
299
300if(CMAKE_SYSTEM_NAME STREQUAL "OS390")
301  enable_language(CXX)
302  list(APPEND uv_defines PATH_MAX=1024)
303  list(APPEND uv_defines _AE_BIMODAL)
304  list(APPEND uv_defines _ALL_SOURCE)
305  list(APPEND uv_defines _ENHANCED_ASCII_EXT=0xFFFFFFFF)
306  list(APPEND uv_defines _ISOC99_SOURCE)
307  list(APPEND uv_defines _LARGE_TIME_API)
308  list(APPEND uv_defines _OPEN_MSGQ_EXT)
309  list(APPEND uv_defines _OPEN_SYS_FILE_EXT)
310  list(APPEND uv_defines _OPEN_SYS_IF_EXT)
311  list(APPEND uv_defines _OPEN_SYS_SOCK_EXT3)
312  list(APPEND uv_defines _OPEN_SYS_SOCK_IPV6)
313  list(APPEND uv_defines _UNIX03_SOURCE)
314  list(APPEND uv_defines _UNIX03_THREADS)
315  list(APPEND uv_defines _UNIX03_WITHDRAWN)
316  list(APPEND uv_defines _XOPEN_SOURCE=600)
317  list(APPEND uv_defines _XOPEN_SOURCE_EXTENDED)
318  list(APPEND uv_sources
319       src/unix/pthread-fixes.c
320       src/unix/os390.c
321       src/unix/os390-syscalls.c
322       src/unix/os390-proctitle.c)
323  list(APPEND uv_cflags
324       -q64
325       -qascii
326       -qexportall
327       -qgonumber
328       -qlongname
329       -qlibansi
330       -qfloat=IEEE
331       -qtune=10
332       -qarch=10
333       -qasm
334       -qasmlib=sys1.maclib:sys1.modgen)
335  find_library(ZOSLIB
336    NAMES zoslib
337    PATHS ${ZOSLIB_DIR}
338    PATH_SUFFIXES lib
339  )
340  list(APPEND uv_libraries ${ZOSLIB})
341endif()
342
343if(CMAKE_SYSTEM_NAME STREQUAL "OS400")
344  list(APPEND uv_defines
345       _ALL_SOURCE
346       _LINUX_SOURCE_COMPAT
347       _THREAD_SAFE
348       _XOPEN_SOURCE=500)
349  list(APPEND uv_sources
350    src/unix/aix-common.c
351    src/unix/ibmi.c
352    src/unix/no-fsevents.c
353    src/unix/posix-poll.c)
354endif()
355
356if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
357  list(APPEND uv_defines __EXTENSIONS__ _XOPEN_SOURCE=500 _REENTRANT)
358  list(APPEND uv_libraries kstat nsl sendfile socket)
359  list(APPEND uv_sources
360       src/unix/no-proctitle.c
361       src/unix/sunos.c)
362endif()
363
364if(CMAKE_SYSTEM_NAME STREQUAL "Haiku")
365  list(APPEND uv_defines _BSD_SOURCE)
366  list(APPEND uv_libraries bsd network)
367  list(APPEND uv_sources
368	  src/unix/haiku.c
369	  src/unix/bsd-ifaddrs.c
370	  src/unix/no-fsevents.c
371	  src/unix/no-proctitle.c
372	  src/unix/posix-hrtime.c
373	  src/unix/posix-poll.c)
374endif()
375
376if(CMAKE_SYSTEM_NAME STREQUAL "QNX")
377  list(APPEND uv_sources
378    src/unix/posix-hrtime.c
379    src/unix/posix-poll.c
380    src/unix/qnx.c
381    src/unix/bsd-ifaddrs.c
382    src/unix/no-proctitle.c
383    src/unix/no-fsevents.c)
384  list(APPEND uv_libraries socket)
385endif()
386
387if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|Linux|NetBSD|OpenBSD")
388  list(APPEND uv_test_libraries util)
389endif()
390
391add_library(uv SHARED ${uv_sources})
392target_compile_definitions(uv
393  INTERFACE
394    USING_UV_SHARED=1
395  PRIVATE
396    BUILDING_UV_SHARED=1
397    ${uv_defines})
398target_compile_options(uv PRIVATE ${uv_cflags})
399target_include_directories(uv
400  PUBLIC
401    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
402    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
403  PRIVATE
404    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
405if(CMAKE_SYSTEM_NAME STREQUAL "OS390")
406  target_include_directories(uv PUBLIC $<BUILD_INTERFACE:${ZOSLIB_DIR}/include>)
407  set_target_properties(uv PROPERTIES LINKER_LANGUAGE CXX)
408endif()
409target_link_libraries(uv ${uv_libraries})
410
411add_library(uv_a STATIC ${uv_sources})
412target_compile_definitions(uv_a PRIVATE ${uv_defines})
413target_compile_options(uv_a PRIVATE ${uv_cflags})
414target_include_directories(uv_a
415  PUBLIC
416    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
417    $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
418  PRIVATE
419    $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
420if(CMAKE_SYSTEM_NAME STREQUAL "OS390")
421  target_include_directories(uv_a PUBLIC $<BUILD_INTERFACE:${ZOSLIB_DIR}/include>)
422  set_target_properties(uv_a PROPERTIES LINKER_LANGUAGE CXX)
423endif()
424target_link_libraries(uv_a ${uv_libraries})
425
426if(LIBUV_BUILD_TESTS)
427  # Small hack: use ${uv_test_sources} now to get the runner skeleton,
428  # before the actual tests are added.
429  add_executable(
430    uv_run_benchmarks_a
431    ${uv_test_sources}
432    test/benchmark-async-pummel.c
433    test/benchmark-async.c
434    test/benchmark-fs-stat.c
435    test/benchmark-getaddrinfo.c
436    test/benchmark-loop-count.c
437    test/benchmark-queue-work.c
438    test/benchmark-million-async.c
439    test/benchmark-million-timers.c
440    test/benchmark-multi-accept.c
441    test/benchmark-ping-pongs.c
442    test/benchmark-ping-udp.c
443    test/benchmark-pound.c
444    test/benchmark-pump.c
445    test/benchmark-sizes.c
446    test/benchmark-spawn.c
447    test/benchmark-tcp-write-batch.c
448    test/benchmark-thread.c
449    test/benchmark-udp-pummel.c
450    test/blackhole-server.c
451    test/echo-server.c
452    test/run-benchmarks.c
453    test/runner.c)
454  target_compile_definitions(uv_run_benchmarks_a PRIVATE ${uv_defines})
455  target_compile_options(uv_run_benchmarks_a PRIVATE ${uv_cflags})
456  target_link_libraries(uv_run_benchmarks_a uv_a ${uv_test_libraries})
457
458  list(APPEND uv_test_sources
459       test/blackhole-server.c
460       test/echo-server.c
461       test/run-tests.c
462       test/runner.c
463       test/test-active.c
464       test/test-async-null-cb.c
465       test/test-async.c
466       test/test-barrier.c
467       test/test-callback-stack.c
468       test/test-close-fd.c
469       test/test-close-order.c
470       test/test-condvar.c
471       test/test-connect-unspecified.c
472       test/test-connection-fail.c
473       test/test-cwd-and-chdir.c
474       test/test-default-loop-close.c
475       test/test-delayed-accept.c
476       test/test-dlerror.c
477       test/test-eintr-handling.c
478       test/test-embed.c
479       test/test-emfile.c
480       test/test-env-vars.c
481       test/test-error.c
482       test/test-fail-always.c
483       test/test-fork.c
484       test/test-fs-copyfile.c
485       test/test-fs-event.c
486       test/test-fs-poll.c
487       test/test-fs.c
488       test/test-fs-readdir.c
489       test/test-fs-fd-hash.c
490       test/test-fs-open-flags.c
491       test/test-get-currentexe.c
492       test/test-get-loadavg.c
493       test/test-get-memory.c
494       test/test-get-passwd.c
495       test/test-getaddrinfo.c
496       test/test-gethostname.c
497       test/test-getnameinfo.c
498       test/test-getsockname.c
499       test/test-getters-setters.c
500       test/test-gettimeofday.c
501       test/test-handle-fileno.c
502       test/test-homedir.c
503       test/test-hrtime.c
504       test/test-idle.c
505       test/test-idna.c
506       test/test-ip4-addr.c
507       test/test-ip6-addr.c
508       test/test-ip-name.c
509       test/test-ipc-heavy-traffic-deadlock-bug.c
510       test/test-ipc-send-recv.c
511       test/test-ipc.c
512       test/test-loop-alive.c
513       test/test-loop-close.c
514       test/test-loop-configure.c
515       test/test-loop-handles.c
516       test/test-loop-stop.c
517       test/test-loop-time.c
518       test/test-metrics.c
519       test/test-multiple-listen.c
520       test/test-mutexes.c
521       test/test-not-readable-nor-writable-on-read-error.c
522       test/test-not-writable-after-shutdown.c
523       test/test-osx-select.c
524       test/test-pass-always.c
525       test/test-ping-pong.c
526       test/test-pipe-bind-error.c
527       test/test-pipe-close-stdout-read-stdin.c
528       test/test-pipe-connect-error.c
529       test/test-pipe-connect-multiple.c
530       test/test-pipe-connect-prepare.c
531       test/test-pipe-getsockname.c
532       test/test-pipe-pending-instances.c
533       test/test-pipe-sendmsg.c
534       test/test-pipe-server-close.c
535       test/test-pipe-set-fchmod.c
536       test/test-pipe-set-non-blocking.c
537       test/test-platform-output.c
538       test/test-poll-close-doesnt-corrupt-stack.c
539       test/test-poll-close.c
540       test/test-poll-closesocket.c
541       test/test-poll-multiple-handles.c
542       test/test-poll-oob.c
543       test/test-poll.c
544       test/test-process-priority.c
545       test/test-process-title-threadsafe.c
546       test/test-process-title.c
547       test/test-queue-foreach-delete.c
548       test/test-random.c
549       test/test-readable-on-eof.c
550       test/test-ref.c
551       test/test-run-nowait.c
552       test/test-run-once.c
553       test/test-semaphore.c
554       test/test-shutdown-close.c
555       test/test-shutdown-eof.c
556       test/test-shutdown-simultaneous.c
557       test/test-shutdown-twice.c
558       test/test-signal-multiple-loops.c
559       test/test-signal-pending-on-close.c
560       test/test-signal.c
561       test/test-socket-buffer-size.c
562       test/test-spawn.c
563       test/test-stdio-over-pipes.c
564       test/test-strscpy.c
565       test/test-strtok.c
566       test/test-tcp-alloc-cb-fail.c
567       test/test-tcp-bind-error.c
568       test/test-tcp-bind6-error.c
569       test/test-tcp-close-accept.c
570       test/test-tcp-close-after-read-timeout.c
571       test/test-tcp-close-while-connecting.c
572       test/test-tcp-close.c
573       test/test-tcp-close-reset.c
574       test/test-tcp-connect-error-after-write.c
575       test/test-tcp-connect-error.c
576       test/test-tcp-connect-timeout.c
577       test/test-tcp-connect6-error.c
578       test/test-tcp-create-socket-early.c
579       test/test-tcp-flags.c
580       test/test-tcp-oob.c
581       test/test-tcp-open.c
582       test/test-tcp-read-stop.c
583       test/test-tcp-read-stop-start.c
584       test/test-tcp-rst.c
585       test/test-tcp-shutdown-after-write.c
586       test/test-tcp-try-write.c
587       test/test-tcp-try-write-error.c
588       test/test-tcp-unexpected-read.c
589       test/test-tcp-write-after-connect.c
590       test/test-tcp-write-fail.c
591       test/test-tcp-write-queue-order.c
592       test/test-tcp-write-to-half-open-connection.c
593       test/test-tcp-writealot.c
594       test/test-test-macros.c
595       test/test-thread-equal.c
596       test/test-thread.c
597       test/test-threadpool-cancel.c
598       test/test-threadpool.c
599       test/test-timer-again.c
600       test/test-timer-from-check.c
601       test/test-timer.c
602       test/test-tmpdir.c
603       test/test-tty-duplicate-key.c
604       test/test-tty-escape-sequence-processing.c
605       test/test-tty.c
606       test/test-udp-alloc-cb-fail.c
607       test/test-udp-bind.c
608       test/test-udp-connect.c
609       test/test-udp-connect6.c
610       test/test-udp-create-socket-early.c
611       test/test-udp-dgram-too-big.c
612       test/test-udp-ipv6.c
613       test/test-udp-mmsg.c
614       test/test-udp-multicast-interface.c
615       test/test-udp-multicast-interface6.c
616       test/test-udp-multicast-join.c
617       test/test-udp-multicast-join6.c
618       test/test-udp-multicast-ttl.c
619       test/test-udp-open.c
620       test/test-udp-options.c
621       test/test-udp-send-and-recv.c
622       test/test-udp-send-hang-loop.c
623       test/test-udp-send-immediate.c
624       test/test-udp-sendmmsg-error.c
625       test/test-udp-send-unreachable.c
626       test/test-udp-try-send.c
627       test/test-uname.c
628       test/test-walk-handles.c
629       test/test-watcher-cross-stop.c)
630
631  add_executable(uv_run_tests ${uv_test_sources} uv_win_longpath.manifest)
632  target_compile_definitions(uv_run_tests
633                             PRIVATE ${uv_defines} USING_UV_SHARED=1)
634  target_compile_options(uv_run_tests PRIVATE ${uv_cflags})
635  target_link_libraries(uv_run_tests uv ${uv_test_libraries})
636  add_test(NAME uv_test
637           COMMAND uv_run_tests
638           WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
639  if(CMAKE_SYSTEM_NAME STREQUAL "OS390")
640    set_tests_properties(uv_test PROPERTIES ENVIRONMENT
641                         "LIBPATH=${CMAKE_BINARY_DIR}:$ENV{LIBPATH}")
642  endif()
643  add_executable(uv_run_tests_a ${uv_test_sources} uv_win_longpath.manifest)
644  target_compile_definitions(uv_run_tests_a PRIVATE ${uv_defines})
645  target_compile_options(uv_run_tests_a PRIVATE ${uv_cflags})
646  if(QEMU)
647    target_link_libraries(uv_run_tests_a uv_a ${uv_test_libraries} -static)
648  else()
649    target_link_libraries(uv_run_tests_a uv_a ${uv_test_libraries})
650  endif()
651  add_test(NAME uv_test_a
652           COMMAND uv_run_tests_a
653           WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
654  if(CMAKE_SYSTEM_NAME STREQUAL "OS390")
655    set_target_properties(uv_run_benchmarks_a PROPERTIES LINKER_LANGUAGE CXX)
656    set_target_properties(uv_run_tests PROPERTIES LINKER_LANGUAGE CXX)
657    set_target_properties(uv_run_tests_a PROPERTIES LINKER_LANGUAGE CXX)
658  endif()
659endif()
660
661# Now for some gibbering horrors from beyond the stars...
662foreach(lib IN LISTS uv_libraries)
663  list(APPEND LIBS "-l${lib}")
664endforeach()
665string(REPLACE ";" " " LIBS "${LIBS}")
666# Consider setting project version via project() call?
667file(STRINGS configure.ac configure_ac REGEX ^AC_INIT)
668string(REGEX MATCH "([0-9]+)[.][0-9]+[.][0-9]+" PACKAGE_VERSION "${configure_ac}")
669set(UV_VERSION_MAJOR "${CMAKE_MATCH_1}")
670# The version in the filename is mirroring the behaviour of autotools.
671set_target_properties(uv PROPERTIES
672  VERSION ${UV_VERSION_MAJOR}.0.0
673  SOVERSION ${UV_VERSION_MAJOR})
674set(includedir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})
675set(libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
676set(prefix ${CMAKE_INSTALL_PREFIX})
677configure_file(libuv.pc.in libuv.pc @ONLY)
678configure_file(libuv-static.pc.in libuv-static.pc @ONLY)
679
680install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
681install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR})
682install(FILES ${PROJECT_BINARY_DIR}/libuv.pc ${PROJECT_BINARY_DIR}/libuv-static.pc
683        DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
684install(TARGETS uv EXPORT libuvConfig
685        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
686        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
687        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
688install(TARGETS uv_a EXPORT libuvConfig
689        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
690install(EXPORT libuvConfig DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libuv)
691
692if(MSVC)
693  set(CMAKE_DEBUG_POSTFIX d)
694endif()
695
696message(STATUS "summary of build options:
697    Install prefix:  ${CMAKE_INSTALL_PREFIX}
698    Target system:   ${CMAKE_SYSTEM_NAME}
699    Compiler:
700      C compiler:    ${CMAKE_C_COMPILER} (${CMAKE_C_COMPILER_ID})
701      CFLAGS:        ${CMAKE_C_FLAGS_${_build_type}} ${CMAKE_C_FLAGS}
702")
703