@@ -24,24 +24,53 @@ cmake_dependent_option(LIBUV_BUILD_BENCH
2424 "Build the benchmarks when building unit tests and we are the root project" ON
2525 "LIBUV_BUILD_TESTS" OFF )
2626
27+ # Qemu Build
28+ option (QEMU "build for qemu" OFF )
29+ if (QEMU)
30+ add_definitions (-D__QEMU__=1 )
31+ endif ()
32+
2733# Compiler check
2834string (CONCAT is-msvc $<OR :
2935 $<C_COMPILER_ID :MSVC >,
3036 $<STREQUAL :${CMAKE_C_COMPILER_FRONTEND_VARIANT} ,MSVC >
3137>)
3238
3339check_c_compiler_flag (/W4 UV_LINT_W4 )
40+ check_c_compiler_flag (/wd4100 UV_LINT_NO_UNUSED_PARAMETER_MSVC )
41+ check_c_compiler_flag (/wd4127 UV_LINT_NO_CONDITIONAL_CONSTANT_MSVC )
42+ check_c_compiler_flag (/wd4201 UV_LINT_NO_NONSTANDARD_MSVC )
43+ check_c_compiler_flag (/wd4206 UV_LINT_NO_NONSTANDARD_EMPTY_TU_MSVC )
44+ check_c_compiler_flag (/wd4210 UV_LINT_NO_NONSTANDARD_FILE_SCOPE_MSVC )
45+ check_c_compiler_flag (/wd4232 UV_LINT_NO_NONSTANDARD_NONSTATIC_DLIMPORT_MSVC )
46+ check_c_compiler_flag (/wd4456 UV_LINT_NO_HIDES_LOCAL )
47+ check_c_compiler_flag (/wd4457 UV_LINT_NO_HIDES_PARAM )
48+ check_c_compiler_flag (/wd4459 UV_LINT_NO_HIDES_GLOBAL )
49+ check_c_compiler_flag (/wd4706 UV_LINT_NO_CONDITIONAL_ASSIGNMENT_MSVC )
50+ check_c_compiler_flag (/wd4996 UV_LINT_NO_UNSAFE_MSVC )
51+
3452check_c_compiler_flag (-Wall UV_LINT_WALL ) # DO NOT use this under MSVC
3553
3654# TODO: Place these into its own function
3755check_c_compiler_flag (-Wno-unused-parameter UV_LINT_NO_UNUSED_PARAMETER )
3856check_c_compiler_flag (-Wstrict-prototypes UV_LINT_STRICT_PROTOTYPES )
3957check_c_compiler_flag (-Wextra UV_LINT_EXTRA )
4058
41- set (lint-no -unused-parameter $<$<BOOL :${UV_LINT_NO_UNUSED_PARAMETER} >:-Wno -unused -parameter >)
59+ set (lint-no -unused-parameter $<$<BOOL :${UV_LINT_NO_UNUSED_PARAMETER} >:-Wno -unused -parameter >)
4260set (lint-strict-prototypes $<$<BOOL :${UV_LINT_STRICT_PROTOTYPES} >:-Wstrict -prototypes >)
4361set (lint-extra $<$<BOOL :${UV_LINT_EXTRA} >:-Wextra >)
4462set (lint-w4 $<$<BOOL :${UV_LINT_W4} >:/W4 >)
63+ set (lint-no -unused-parameter-msvc $<$<BOOL :${UV_LINT_NO_UNUSED_PARAMETER_MSVC} >:/wd4100 >)
64+ set (lint-no -conditional-constant-msvc $<$<BOOL :${UV_LINT_NO_CONDITIONAL_CONSTANT_MSVC} >:/wd4127 >)
65+ set (lint-no -nonstandard-msvc $<$<BOOL :${UV_LINT_NO_NONSTANDARD_MSVC} >:/wd4201 >)
66+ set (lint-no -nonstandard-empty-tu-msvc $<$<BOOL :${UV_LINT_NO_NONSTANDARD_EMPTY_TU_MSVC} >:/wd4206 >)
67+ set (lint-no -nonstandard-file-scope-msvc $<$<BOOL :${UV_LINT_NO_NONSTANDARD_FILE_SCOPE_MSVC} >:/wd4210 >)
68+ set (lint-no -nonstandard-nonstatic-dlimport-msvc $<$<BOOL :${UV_LINT_NO_NONSTANDARD_NONSTATIC_DLIMPORT_MSVC} >:/wd4232 >)
69+ set (lint-no -hides-local-msvc $<$<BOOL :${UV_LINT_NO_HIDES_LOCAL} >:/wd4456 >)
70+ set (lint-no -hides-param-msvc $<$<BOOL :${UV_LINT_NO_HIDES_PARAM} >:/wd4457 >)
71+ set (lint-no -hides-global-msvc $<$<BOOL :${UV_LINT_NO_HIDES_GLOBAL} >:/wd4459 >)
72+ set (lint-no -conditional-assignment-msvc $<$<BOOL :${UV_LINT_NO_CONDITIONAL_ASSIGNMENT_MSVC} >:/wd4706 >)
73+ set (lint-no -unsafe-msvc $<$<BOOL :${UV_LINT_NO_UNSAFE_MSVC} >:/wd4996 >)
4574# Unfortunately, this one is complicated because MSVC and clang-cl support -Wall
4675# but using it is like calling -Weverything
4776string (CONCAT lint-default $<
@@ -50,6 +79,17 @@ string(CONCAT lint-default $<
5079
5180list (APPEND uv_cflags ${lint-strict-prototypes} ${lint-extra} ${lint-default} ${lint-w4})
5281list (APPEND uv_cflags ${lint-no -unused-parameter})
82+ list (APPEND uv_cflags ${lint-no -unused-parameter-msvc })
83+ list (APPEND uv_cflags ${lint-no -conditional-constant-msvc })
84+ list (APPEND uv_cflags ${lint-no -nonstandard-msvc })
85+ list (APPEND uv_cflags ${lint-no -nonstandard-empty-tu-msvc })
86+ list (APPEND uv_cflags ${lint-no -nonstandard-file-scope-msvc })
87+ list (APPEND uv_cflags ${lint-no -nonstandard-nonstatic-dlimport-msvc })
88+ list (APPEND uv_cflags ${lint-no -hides-local-msvc })
89+ list (APPEND uv_cflags ${lint-no -hides-param-msvc })
90+ list (APPEND uv_cflags ${lint-no -hides-global-msvc })
91+ list (APPEND uv_cflags ${lint-no -conditional-assignment-msvc })
92+ list (APPEND uv_cflags ${lint-no -unsafe-msvc })
5393
5494set (uv_sources
5595 src/fs-poll.c
@@ -64,22 +104,9 @@ set(uv_sources
64104 src/version.c)
65105
66106if (WIN32 )
67- if (CMAKE_SYSTEM_VERSION VERSION_GREATER 10) # Windows 10
68- set (windows-version 0x0A00)
69- elseif (CMAKE_SYSTEM_VERSION VERSION_GREATER 6.3) # Windows 8.1
70- set (windows-version 0x0603)
71- elseif (CMAKE_SYSTEM_VERSION VERSION_GREATER 6.2) # Windows 8
72- set (windows-version 0x0602)
73- elseif (CMAKE_SYSTEM_VERSION VERSION_GREATER 6.1) # Windows 7
74- set (windows-version 0x0601)
75- elseif (CMAKE_SYSTEM_VERSION VERSION_GREATER 6.0) # Windows Vista
76- set (windows-version 0x0600)
77- else ()
78- message (FATAL_ERROR "Windows Vista is the minimum version supported" )
79- endif ()
80- list (APPEND uv_defines WIN32_LEAN_AND_MEAN _WIN32_WINNT=${windows-version})
107+ list (APPEND uv_defines WIN32_LEAN_AND_MEAN _WIN32_WINNT=0x0600)
81108 list (APPEND uv_libraries
82- $<$< STREQUAL :${ windows - version },0 x0600 >: psapi >
109+ psapi
83110 iphlpapi
84111 userenv
85112 ws2_32)
@@ -155,7 +182,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "AIX")
155182endif ()
156183
157184if (CMAKE_SYSTEM_NAME STREQUAL "Android" )
158- list (APPEND uv_libs dl)
185+ list (APPEND uv_libraries dl)
159186 list (APPEND uv_sources
160187 src/unix /android -ifaddrs.c
161188 src/unix /linux -core.c
@@ -489,7 +516,7 @@ if(LIBUV_BUILD_TESTS)
489516 test/test-walk-handles.c
490517 test/test-watcher-cross-stop.c)
491518
492- add_executable (uv_run_tests ${uv_test_sources} )
519+ add_executable (uv_run_tests ${uv_test_sources} uv_win_longpath.manifest )
493520 target_compile_definitions (uv_run_tests
494521 PRIVATE ${uv_defines} USING_UV_SHARED=1 )
495522 target_compile_options (uv_run_tests PRIVATE ${uv_cflags} )
@@ -501,10 +528,14 @@ if(LIBUV_BUILD_TESTS)
501528 set_tests_properties (uv_test PROPERTIES ENVIRONMENT
502529 "LIBPATH=${CMAKE_BINARY_DIR} :$ENV{LIBPATH} " )
503530 endif ()
504- add_executable (uv_run_tests_a ${uv_test_sources} )
531+ add_executable (uv_run_tests_a ${uv_test_sources} uv_win_longpath.manifest )
505532 target_compile_definitions (uv_run_tests_a PRIVATE ${uv_defines} )
506533 target_compile_options (uv_run_tests_a PRIVATE ${uv_cflags} )
507- target_link_libraries (uv_run_tests_a uv_a ${uv_test_libraries} )
534+ if (QEMU)
535+ target_link_libraries (uv_run_tests_a uv_a ${uv_test_libraries} -static )
536+ else ()
537+ target_link_libraries (uv_run_tests_a uv_a ${uv_test_libraries} )
538+ endif ()
508539 add_test (NAME uv_test_a
509540 COMMAND uv_run_tests_a
510541 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
@@ -544,3 +575,11 @@ if(WIN32)
544575 RUNTIME DESTINATION lib/$<CONFIG >
545576 ARCHIVE DESTINATION lib/$<CONFIG >)
546577endif ()
578+
579+ message (STATUS "summary of build options:
580+ Install prefix: ${CMAKE_INSTALL_PREFIX}
581+ Target system: ${CMAKE_SYSTEM_NAME}
582+ Compiler:
583+ C compiler: ${CMAKE_C_COMPILER}
584+ CFLAGS: ${CMAKE_C_FLAGS_${_build_type} } ${CMAKE_C_FLAGS}
585+ " )
0 commit comments