From 27417bc6f92a6c577790b23e21c79f7fd820cfff Mon Sep 17 00:00:00 2001 From: "Ding, Yi1" Date: Wed, 21 Feb 2024 18:29:50 -0800 Subject: [PATCH] move win waring flags to Common.cmake --- CMakeLists.txt | 19 ------------------- neural_speed/cmake/Common.cmake | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 72ced26d7..c8e4d6c82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,28 +96,9 @@ endif() if (MSVC) add_compile_definitions(_CRT_SECURE_NO_WARNINGS NOMINMAX) - add_compile_options(/wd4244 /wd4267) # possible loss of data - add_compile_options(/wd4305) # truncation from 'double' to 'float' - add_compile_options(/wd4018) # '>': signed/unsigned mismatch - add_compile_options(/wd4334) # '<<': result of 32-bit shift implicitly converted to 64 bits if (BUILD_SHARED_LIBS) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) endif() - - # 'std::codecvt_utf8': warning STL4017: std::wbuffer_convert, - # std::wstring_convert, and the header (containing std::codecvt_mode, std::codecvt_utf8, - # std::codecvt_utf16, and std::codecvt_utf8_utf16) are deprecated in C++17. (The std::codecvt class template is NOT - # deprecated.) The C++ Standard doesn't provide equivalent non-deprecated functionality; consider using - # MultiByteToWideChar() and WideCharToMultiByte() from instead. You can define - # _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this - # warning. - add_compile_definitions(_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING) - - # Microsoft renamed some POSIX and Microsoft-specific library functions in the CRT to conform with C99 and C++03 - # constraints on reserved and global implementation-defined names. If you need to use the existing function names - # for portability reasons, you can turn off these warnings. The functions are still available in the library under - # their original names. - add_compile_definitions(_CRT_NONSTDC_NO_WARNINGS) endif() set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) # default to false so that pybind11 will not try to use IPO diff --git a/neural_speed/cmake/Common.cmake b/neural_speed/cmake/Common.cmake index 8dd58a43b..891bbbd38 100644 --- a/neural_speed/cmake/Common.cmake +++ b/neural_speed/cmake/Common.cmake @@ -18,6 +18,27 @@ function(warning_check TARGET) # target_compile_definitions(${TARGET} PUBLIC -DPLATFORM_WINDOWS -DNOGDI -DNOMINMAX -D_USE_MATH_DEFINES -D_SILENCE_ALL_CXX17_DEPRECATION_WARNINGS) target_compile_options(${TARGET} PRIVATE "$<$:SHELL:--compiler-options /utf-8>" "$<$>:/utf-8>") # target_compile_options(${TARGET} PRIVATE "$<$:SHELL:--compiler-options /sdl>" "$<$>:/sdl>") + + # Use public to affect pybind targets + target_compile_options(${TARGET} PUBLIC /wd4244 /wd4267) # possible loss of data + target_compile_options(${TARGET} PUBLIC /wd4305) # truncation from 'double' to 'float' + target_compile_options(${TARGET} PUBLIC /wd4018) # '>': signed/unsigned mismatch + target_compile_options(${TARGET} PUBLIC /wd4334) # '<<': result of 32-bit shift implicitly converted to 64 bits + + # 'std::codecvt_utf8': warning STL4017: std::wbuffer_convert, + # std::wstring_convert, and the header (containing std::codecvt_mode, std::codecvt_utf8, + # std::codecvt_utf16, and std::codecvt_utf8_utf16) are deprecated in C++17. (The std::codecvt class template is NOT + # deprecated.) The C++ Standard doesn't provide equivalent non-deprecated functionality; consider using + # MultiByteToWideChar() and WideCharToMultiByte() from instead. You can define + # _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING or _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS to suppress this + # warning. + target_compile_definitions(${TARGET} PUBLIC _SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING) + + # Microsoft renamed some POSIX and Microsoft-specific library functions in the CRT to conform with C99 and C++03 + # constraints on reserved and global implementation-defined names. If you need to use the existing function names + # for portability reasons, you can turn off these warnings. The functions are still available in the library under + # their original names. + target_compile_definitions(${TARGET} PUBLIC _CRT_NONSTDC_NO_WARNINGS) else() # # Enable warning # target_compile_options(${TARGET} PRIVATE "$<$:SHELL:--compiler-options -Wall>" "$<$>:-Wall>")