Skip to content

Commit caea9ad

Browse files
committed
whisper: suppress Windows compiler warnings
This commit disables compiler warnings on window using MSVC. The motivation for these changes is that some compilers generate warnings for these conversion, for example Windows MSVC, and there are quite a few of them. This makes it a little difficult to spot new warnings that may be introduced and also can be difficult for users/embedders of ggml where these warnings are hard to separate from their own warnings.
1 parent b7db9e7 commit caea9ad

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

CMakeLists.txt

+34
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,37 @@ endif ()
213213
if (WHISPER_BUILD_EXAMPLES)
214214
add_subdirectory(examples)
215215
endif()
216+
217+
if(MSVC)
218+
set(MSVC_WARNING_FLAGS
219+
/wd4101 # Unreferenced local variable
220+
/wd4005 # Macro redefinition
221+
/wd4267 # Conversion from 'size_t' to a smaller type, possible loss of data
222+
/wd4244 # Conversion from one type to another type, possible loss of data
223+
/wd4267 # Duplicate of 4267 above - you might want to remove this duplicate
224+
/wd4305 # Truncation from 'type1' to 'type2' (often double to float)
225+
/wd4996 # Function or variable may be unsafe/deprecated
226+
)
227+
function(disable_msvc_warnings target_name)
228+
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
229+
endfunction()
230+
231+
disable_msvc_warnings(ggml-base)
232+
disable_msvc_warnings(ggml)
233+
disable_msvc_warnings(ggml-cpu)
234+
235+
if (WHISPER_BUILD_EXAMPLES)
236+
message(STATUS "Disabling MSVC warnings for examples")
237+
disable_msvc_warnings(common)
238+
disable_msvc_warnings(common-sdl)
239+
disable_msvc_warnings(lsp)
240+
disable_msvc_warnings(wchess-core)
241+
disable_msvc_warnings(whisper-command)
242+
disable_msvc_warnings(whisper-cli)
243+
disable_msvc_warnings(whisper-server)
244+
disable_msvc_warnings(whisper-stream)
245+
disable_msvc_warnings(whisper-talk-llama)
246+
disable_msvc_warnings(whisper-bench)
247+
disable_msvc_warnings(quantize)
248+
endif()
249+
endif()

0 commit comments

Comments
 (0)