Skip to content

Commit 0f49edf

Browse files
authored
whisper : add check that target name exists (#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: #3090 (comment)
1 parent 25efcfe commit 0f49edf

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ if (MSVC)
226226
/wd4996 # Function or variable may be unsafe/deprecated
227227
)
228228
function(disable_msvc_warnings target_name)
229-
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
229+
if(TARGET ${target_name})
230+
target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
231+
endif()
230232
endfunction()
231233

232234
if (WHISPER_BUILD_EXAMPLES)

ggml/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)