danbev commited on
Commit
60ff3ed
·
unverified ·
1 Parent(s): 1eb0f64

whisper : add check that target name exists (#3103)

Browse files

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: https://github.com/ggml-org/whisper.cpp/pull/3090#issuecomment-2842760104

Files changed (2) hide show
  1. CMakeLists.txt +3 -1
  2. ggml/CMakeLists.txt +10 -1
CMakeLists.txt CHANGED
@@ -226,7 +226,9 @@ if (MSVC)
226
  /wd4996 # Function or variable may be unsafe/deprecated
227
  )
228
  function(disable_msvc_warnings target_name)
229
- target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
 
 
230
  endfunction()
231
 
232
  if (WHISPER_BUILD_EXAMPLES)
 
226
  /wd4996 # Function or variable may be unsafe/deprecated
227
  )
228
  function(disable_msvc_warnings target_name)
229
+ if(TARGET ${target_name})
230
+ target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
231
+ endif()
232
  endfunction()
233
 
234
  if (WHISPER_BUILD_EXAMPLES)
ggml/CMakeLists.txt CHANGED
@@ -368,10 +368,19 @@ if (MSVC)
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)
 
 
 
 
 
 
 
377
  endif()
 
368
  /wd4267 # Conversion from 'size_t' to a smaller type, possible loss of data
369
  )
370
  function(disable_msvc_warnings target_name)
371
+ if(TARGET ${target_name})
372
+ target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
373
+ endif()
374
  endfunction()
375
 
376
  disable_msvc_warnings(ggml-base)
377
  disable_msvc_warnings(ggml)
378
  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)
386
  endif()