@@ -31,13 +31,26 @@ if(QEMU)
3131endif ()
3232
3333option (ASAN "Enable AddressSanitizer (ASan)" OFF )
34- if (ASAN AND CMAKE_C_COMPILER_ID MATCHES "AppleClang|GNU|Clang" )
34+ option (TSAN "Enable ThreadSanitizer (TSan)" OFF )
35+
36+ if ((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." )
38+ endif ()
39+
40+ if (ASAN)
3541 add_definitions (-D__ASAN__=1)
36- set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG } -fno-omit-frame-pointer -fsanitize=address" )
37- set (CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG } -fno-omit-frame-pointer -fsanitize=address" )
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" )
3844 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fno-omit-frame-pointer -fsanitize=address" )
3945endif ()
4046
47+ if (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" )
52+ endif ()
53+
4154# Compiler check
4255string (CONCAT is-msvc $<OR :
4356 $<C_COMPILER_ID:MSVC >,
@@ -418,7 +431,6 @@ if(LIBUV_BUILD_TESTS)
418431 test /benchmark-thread.c
419432 test /benchmark-udp-pummel.c
420433 test /blackhole-server.c
421- test /dns-server.c
422434 test /echo-server.c
423435 test /run-benchmarks.c
424436 test /runner.c)
@@ -477,6 +489,7 @@ if(LIBUV_BUILD_TESTS)
477489 test /test -idna.c
478490 test /test -ip4-addr.c
479491 test /test -ip6-addr.c
492+ test /test -ip-name .c
480493 test /test -ipc-heavy-traffic-deadlock-bug.c
481494 test /test -ipc-send-recv.c
482495 test /test -ipc.c
@@ -490,7 +503,6 @@ if(LIBUV_BUILD_TESTS)
490503 test /test -multiple-listen.c
491504 test /test -mutexes.c
492505 test /test -not -readable-nor-writable-on -read-error.c
493- test /test -not -readable-on -eof.c
494506 test /test -not -writable-after-shutdown.c
495507 test /test -osx-select.c
496508 test /test -pass-always.c
@@ -518,6 +530,7 @@ if(LIBUV_BUILD_TESTS)
518530 test /test -process-title.c
519531 test /test -queue-foreach-delete.c
520532 test /test -random.c
533+ test /test -readable-on -eof.c
521534 test /test -ref.c
522535 test /test -run-nowait.c
523536 test /test -run-once.c
@@ -574,6 +587,7 @@ if(LIBUV_BUILD_TESTS)
574587 test /test -udp-alloc-cb-fail.c
575588 test /test -udp-bind.c
576589 test /test -udp-connect.c
590+ test /test -udp-connect6.c
577591 test /test -udp-create-socket-early.c
578592 test /test -udp-dgram-too-big.c
579593 test /test -udp-ipv6.c
@@ -625,46 +639,43 @@ if(LIBUV_BUILD_TESTS)
625639 endif ()
626640endif ()
627641
628- if (UNIX OR MINGW)
629- # Now for some gibbering horrors from beyond the stars...
630- foreach (lib IN LISTS uv_libraries)
631- list (APPEND LIBS "-l${lib} " )
632- endforeach ()
633- string (REPLACE ";" " " LIBS "${LIBS} " )
634- # Consider setting project version via project() call?
635- file (STRINGS configure.ac configure_ac REGEX ^AC_INIT)
636- string (REGEX MATCH "([0-9]+)[.][0-9]+[.][0-9]+" PACKAGE_VERSION "${configure_ac} " )
637- set (UV_VERSION_MAJOR "${CMAKE_MATCH_1} " )
638- # The version in the filename is mirroring the behaviour of autotools.
639- set_target_properties (uv PROPERTIES
640- VERSION ${UV_VERSION_MAJOR} .0.0
641- SOVERSION ${UV_VERSION_MAJOR} )
642- set (includedir ${CMAKE_INSTALL_PREFIX} /${CMAKE_INSTALL_INCLUDEDIR} )
643- set (libdir ${CMAKE_INSTALL_PREFIX} /${CMAKE_INSTALL_LIBDIR} )
644- set (prefix ${CMAKE_INSTALL_PREFIX} )
645- configure_file (libuv.pc.in libuv.pc @ONLY)
646- configure_file (libuv-static .pc.in libuv-static .pc @ONLY)
647-
648- install (DIRECTORY include / DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
649- install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR} )
650- install (FILES ${PROJECT_BINARY_DIR} /libuv.pc ${PROJECT_BINARY_DIR} /libuv-static .pc
651- DESTINATION ${CMAKE_INSTALL_LIBDIR} /pkgconfig)
652- install (TARGETS uv LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
653- install (TARGETS uv_a ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} )
654- endif ()
642+ # Now for some gibbering horrors from beyond the stars...
643+ foreach (lib IN LISTS uv_libraries)
644+ list (APPEND LIBS "-l${lib} " )
645+ endforeach ()
646+ string (REPLACE ";" " " LIBS "${LIBS} " )
647+ # Consider setting project version via project() call?
648+ file (STRINGS configure.ac configure_ac REGEX ^AC_INIT)
649+ string (REGEX MATCH "([0-9]+)[.][0-9]+[.][0-9]+" PACKAGE_VERSION "${configure_ac} " )
650+ set (UV_VERSION_MAJOR "${CMAKE_MATCH_1} " )
651+ # The version in the filename is mirroring the behaviour of autotools.
652+ set_target_properties (uv PROPERTIES
653+ VERSION ${UV_VERSION_MAJOR} .0.0
654+ SOVERSION ${UV_VERSION_MAJOR} )
655+ set (includedir ${CMAKE_INSTALL_PREFIX} /${CMAKE_INSTALL_INCLUDEDIR} )
656+ set (libdir ${CMAKE_INSTALL_PREFIX} /${CMAKE_INSTALL_LIBDIR} )
657+ set (prefix ${CMAKE_INSTALL_PREFIX} )
658+ configure_file (libuv.pc.in libuv.pc @ONLY)
659+ configure_file (libuv-static .pc.in libuv-static .pc @ONLY)
660+
661+ install (DIRECTORY include / DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} )
662+ install (FILES LICENSE DESTINATION ${CMAKE_INSTALL_DOCDIR} )
663+ install (FILES ${PROJECT_BINARY_DIR} /libuv.pc ${PROJECT_BINARY_DIR} /libuv-static .pc
664+ DESTINATION ${CMAKE_INSTALL_LIBDIR} /pkgconfig)
665+ install (TARGETS uv EXPORT libuvConfig
666+ RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
667+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} )
668+ install (TARGETS uv_a ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} )
669+ install (EXPORT libuvConfig DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/libuv)
655670
656671if (MSVC )
657- install (DIRECTORY include / DESTINATION include )
658- install (FILES LICENSE DESTINATION .)
659- install (TARGETS uv uv_a
660- RUNTIME DESTINATION lib/$<CONFIG>
661- ARCHIVE DESTINATION lib/$<CONFIG>)
672+ set (CMAKE_DEBUG_POSTFIX d)
662673endif ()
663674
664675message (STATUS "summary of build options:
665676 Install prefix: ${CMAKE_INSTALL_PREFIX}
666677 Target system: ${CMAKE_SYSTEM_NAME}
667678 Compiler:
668- C compiler: ${CMAKE_C_COMPILER}
679+ C compiler: ${CMAKE_C_COMPILER} ( ${CMAKE_C_COMPILER_ID} )
669680 CFLAGS: ${CMAKE_C_FLAGS_${_build_type} } ${CMAKE_C_FLAGS}
670681" )
0 commit comments