Skip to content
This repository has been archived by the owner on Aug 30, 2024. It is now read-only.

Commit

Permalink
move win waring flags to Common.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
DDEle committed Feb 22, 2024
1 parent a5253e2 commit 27417bc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
19 changes: 0 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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<wchar_t,1114111,(std::codecvt_mode)0>': warning STL4017: std::wbuffer_convert,
# std::wstring_convert, and the <codecvt> 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 <Windows.h> 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
Expand Down
21 changes: 21 additions & 0 deletions neural_speed/cmake/Common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 "$<$<COMPILE_LANGUAGE:DPCPP>:SHELL:--compiler-options /utf-8>" "$<$<NOT:$<COMPILE_LANGUAGE:DPCPP>>:/utf-8>")
# target_compile_options(${TARGET} PRIVATE "$<$<COMPILE_LANGUAGE:DPCPP>:SHELL:--compiler-options /sdl>" "$<$<NOT:$<COMPILE_LANGUAGE:DPCPP>>:/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<wchar_t,1114111,(std::codecvt_mode)0>': warning STL4017: std::wbuffer_convert,
# std::wstring_convert, and the <codecvt> 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 <Windows.h> 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 "$<$<COMPILE_LANGUAGE:DPCPP>:SHELL:--compiler-options -Wall>" "$<$<NOT:$<COMPILE_LANGUAGE:DPCPP>>:-Wall>")
Expand Down

0 comments on commit 27417bc

Please sign in to comment.