Skip to content

Commit 5a3b467

Browse files
committed
Disable breaking MSVC Warning CMakeFiles.txt if GGML_CPU_ALL_VARIANTS
1 parent 5ec6ad5 commit 5a3b467

File tree

2 files changed

+46
-40
lines changed

2 files changed

+46
-40
lines changed

CMakeLists.txt

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -218,32 +218,35 @@ if (WHISPER_BUILD_EXAMPLES)
218218
add_subdirectory(examples)
219219
endif()
220220

221-
if (MSVC)
222-
set(MSVC_WARNING_FLAGS
223-
/wd4101 # Unreferenced local variable
224-
/wd4005 # Macro redefinition
225-
/wd4065 # switch statement contains 'default' but no 'case' labels
226-
/wd4267 # Conversion from 'size_t' to a smaller type, possible loss of data
227-
/wd4244 # Conversion from one type to another type, possible loss of ata
228-
/wd4805 # Unsafe mix of type
229-
/wd4305 # Truncation from 'type1' to 'type2' (often double to float)
230-
/wd4996 # Function or variable may be unsafe/deprecated
231-
)
232-
function(disable_msvc_warnings target_name)
233-
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
234-
endfunction()
235-
236-
if (WHISPER_BUILD_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)
221+
### The following breaks GGML_CPU_ALL_VARIANTS ###
222+
if(NOT DEFINED GGML_CPU_ALL_VARIANTS)
223+
if (MSVC)
224+
set(MSVC_WARNING_FLAGS
225+
/wd4101 # Unreferenced local variable
226+
/wd4005 # Macro redefinition
227+
/wd4065 # switch statement contains 'default' but no 'case' labels
228+
/wd4267 # Conversion from 'size_t' to a smaller type, possible loss of data
229+
/wd4244 # Conversion from one type to another type, possible loss of ata
230+
/wd4805 # Unsafe mix of type
231+
/wd4305 # Truncation from 'type1' to 'type2' (often double to float)
232+
/wd4996 # Function or variable may be unsafe/deprecated
233+
)
234+
function(disable_msvc_warnings target_name)
235+
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
236+
endfunction()
237+
238+
if (WHISPER_BUILD_EXAMPLES)
239+
disable_msvc_warnings(common)
240+
disable_msvc_warnings(common-sdl)
241+
disable_msvc_warnings(lsp)
242+
disable_msvc_warnings(wchess-core)
243+
disable_msvc_warnings(whisper-command)
244+
disable_msvc_warnings(whisper-cli)
245+
disable_msvc_warnings(whisper-server)
246+
disable_msvc_warnings(whisper-stream)
247+
disable_msvc_warnings(whisper-talk-llama)
248+
disable_msvc_warnings(whisper-bench)
249+
disable_msvc_warnings(quantize)
250+
endif()
248251
endif()
249252
endif()

ggml/CMakeLists.txt

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -361,17 +361,20 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ggml-config.cmake
361361
${CMAKE_CURRENT_BINARY_DIR}/ggml-version.cmake
362362
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ggml)
363363

364-
if (MSVC)
365-
set(MSVC_WARNING_FLAGS
366-
/wd4005 # Macro redefinition
367-
/wd4244 # Conversion from one type to another type, possible loss of data
368-
/wd4267 # Conversion from 'size_t' to a smaller type, possible loss of data
369-
)
370-
function(disable_msvc_warnings target_name)
371-
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
372-
endfunction()
373-
374-
disable_msvc_warnings(ggml-base)
375-
disable_msvc_warnings(ggml)
376-
disable_msvc_warnings(ggml-cpu)
364+
### The following breaks GGML_CPU_ALL_VARIANTS ###
365+
if(NOT DEFINED GGML_CPU_ALL_VARIANTS)
366+
if (MSVC)
367+
set(MSVC_WARNING_FLAGS
368+
/wd4005 # Macro redefinition
369+
/wd4244 # Conversion from one type to another type, possible loss of data
370+
/wd4267 # Conversion from 'size_t' to a smaller type, possible loss of data
371+
)
372+
function(disable_msvc_warnings target_name)
373+
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
374+
endfunction()
375+
376+
disable_msvc_warnings(ggml-base)
377+
disable_msvc_warnings(ggml)
378+
disable_msvc_warnings(ggml-cpu)
379+
endif()
377380
endif()

0 commit comments

Comments
 (0)