1
1
# TODO: determine CMAKE_SYSTEM_NAME on OS/390. Currently assumes "OS/390".
2
- cmake_minimum_required (VERSION 2.8.12)
3
- project (libuv)
2
+ cmake_minimum_required (VERSION 3.4)
3
+ project (libuv LANGUAGES C)
4
+
5
+ include (CMakePackageConfigHelpers)
6
+ include (CMakeDependentOption)
7
+ include (GNUInstallDirs)
8
+ include (CTest)
9
+
10
+ cmake_dependent_option(LIBUV_BUILD_TESTS
11
+ "Build the unit tests when BUILD_TESTING is enabled and we are the root project" ON
12
+ "BUILD_TESTING;CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR" OFF )
4
13
5
14
if (MSVC )
6
15
list (APPEND uv_cflags /W4)
@@ -14,6 +23,7 @@ set(uv_sources
14
23
src/fs-poll.c
15
24
src/idna.c
16
25
src/inet.c
26
+ src/random.c
17
27
src/strscpy.c
18
28
src/threadpool.c
19
29
src/timer.c
@@ -72,7 +82,6 @@ set(uv_test_sources
72
82
test /test -idna.c
73
83
test /test -ip4-addr.c
74
84
test /test -ip6-addr.c
75
- test /test -ip6-addr.c
76
85
test /test -ipc-heavy-traffic-deadlock-bug.c
77
86
test /test -ipc-send-recv.c
78
87
test /test -ipc.c
@@ -108,6 +117,7 @@ set(uv_test_sources
108
117
test /test -process-title-threadsafe.c
109
118
test /test -process-title.c
110
119
test /test -queue-foreach-delete.c
120
+ test /test -random.c
111
121
test /test -ref.c
112
122
test /test -run-nowait.c
113
123
test /test -run-once.c
@@ -236,6 +246,7 @@ else()
236
246
src/unix /pipe.c
237
247
src/unix /poll.c
238
248
src/unix /process.c
249
+ src/unix /random-devurandom.c
239
250
src/unix /signal.c
240
251
src/unix /stream.c
241
252
src/unix /tcp.c
@@ -284,6 +295,14 @@ if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "DragonFly|FreeBSD|NetBSD|OpenBSD")
284
295
list (APPEND uv_sources src/unix /bsd-ifaddrs.c src/unix /kqueue.c)
285
296
endif ()
286
297
298
+ if (CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
299
+ list (APPEND uv_sources src/unix /random-getrandom.c)
300
+ endif ()
301
+
302
+ if (APPLE OR CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" )
303
+ list (APPEND uv_sources src/unix /random-getentropy.c)
304
+ endif ()
305
+
287
306
if (APPLE )
288
307
list (APPEND uv_defines _DARWIN_UNLIMITED_SELECT=1 _DARWIN_USE_64_BIT_INODE=1)
289
308
list (APPEND uv_sources
@@ -300,6 +319,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
300
319
src/unix /linux-inotify.c
301
320
src/unix /linux-syscalls.c
302
321
src/unix /procfs-exepath.c
322
+ src/unix /random-getrandom.c
323
+ src/unix /random-sysctl.c
303
324
src/unix /sysinfo-loadavg.c)
304
325
endif ()
305
326
@@ -356,11 +377,7 @@ target_compile_options(uv_a PRIVATE ${uv_cflags})
356
377
target_include_directories (uv_a PUBLIC include PRIVATE src)
357
378
target_link_libraries (uv_a ${uv_libraries} )
358
379
359
- option (libuv_buildtests "Build the unit tests when BUILD_TESTING is enabled." ON )
360
-
361
- include (CTest)
362
- if (BUILD_TESTING AND libuv_buildtests)
363
- enable_testing ()
380
+ if (LIBUV_BUILD_TESTS)
364
381
add_executable (uv_run_tests ${uv_test_sources} )
365
382
target_compile_definitions (uv_run_tests
366
383
PRIVATE ${uv_defines} USING_UV_SHARED=1)
@@ -380,7 +397,6 @@ endif()
380
397
381
398
if (UNIX )
382
399
# Now for some gibbering horrors from beyond the stars...
383
- include (GNUInstallDirs)
384
400
foreach (x ${uv_libraries} )
385
401
set (LIBS "${LIBS} -l${x} " )
386
402
endforeach (x)
@@ -402,3 +418,11 @@ if(UNIX)
402
418
install (TARGETS uv LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
403
419
install (TARGETS uv_a ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} )
404
420
endif ()
421
+
422
+ if (WIN32 )
423
+ install (DIRECTORY include / DESTINATION include )
424
+ install (FILES LICENSE DESTINATION .)
425
+ install (TARGETS uv uv_a
426
+ RUNTIME DESTINATION lib/$<CONFIG>
427
+ ARCHIVE DESTINATION lib/$<CONFIG>)
428
+ endif ()
0 commit comments