Skip to content

Commit 54e6452

Browse files
danbevggerganov
authored andcommitted
whisper : add check that target name exists (whisper/3103)
This commit adds a check to makes sure that the target exists before trying to add compile options to ignore warnings when using MSVC. The motivation for this is currently the build is broken depending on the cmake options provided. With this fix it should be possible to build even if the targets are not actually available. Refs: ggml-org/whisper.cpp#3090 (comment)
1 parent 0af300e commit 54e6452

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

CMakeLists.txt

+10-1
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,19 @@ if (MSVC)
368368
/wd4267 # Conversion from 'size_t' to a smaller type, possible loss of data
369369
)
370370
function(disable_msvc_warnings target_name)
371-
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
371+
if(TARGET ${target_name})
372+
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
373+
endif()
372374
endfunction()
373375

374376
disable_msvc_warnings(ggml-base)
375377
disable_msvc_warnings(ggml)
376378
disable_msvc_warnings(ggml-cpu)
379+
disable_msvc_warnings(ggml-cpu-x64)
380+
disable_msvc_warnings(ggml-cpu-sse42)
381+
disable_msvc_warnings(ggml-cpu-sandybridge)
382+
disable_msvc_warnings(ggml-cpu-haswell)
383+
disable_msvc_warnings(ggml-cpu-skylakex)
384+
disable_msvc_warnings(ggml-cpu-icelake)
385+
disable_msvc_warnings(ggml-cpu-alderlake)
377386
endif()

0 commit comments

Comments
 (0)