]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
whisper : add check that target name exists (#3103)
authorDaniel Bevenius <redacted>
Thu, 1 May 2025 08:05:24 +0000 (10:05 +0200)
committerGitHub <redacted>
Thu, 1 May 2025 08:05:24 +0000 (10:05 +0200)
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

CMakeLists.txt
ggml/CMakeLists.txt

index ec750928247cc46ad41880f9021439c6b14afcdc..fe82c65d103b7a40d2171e324c1dacb39ba72a33 100644 (file)
@@ -226,7 +226,9 @@ if (MSVC)
         /wd4996  # Function or variable may be unsafe/deprecated
     )
     function(disable_msvc_warnings target_name)
-        target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
+        if(TARGET ${target_name})
+            target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
+        endif()
     endfunction()
 
     if (WHISPER_BUILD_EXAMPLES)
index e632af010c76bbe8161040c6ec7919dba04061f2..b463cbd9b3c397c3985e00fc448e90a0a230c383 100644 (file)
@@ -368,10 +368,19 @@ if (MSVC)
         /wd4267  # Conversion from 'size_t' to a smaller type, possible loss of data
     )
     function(disable_msvc_warnings target_name)
-        target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
+        if(TARGET ${target_name})
+            target_compile_options(${target_name} PRIVATE ${MSVC_WARNING_FLAGS})
+        endif()
     endfunction()
 
     disable_msvc_warnings(ggml-base)
     disable_msvc_warnings(ggml)
     disable_msvc_warnings(ggml-cpu)
+    disable_msvc_warnings(ggml-cpu-x64)
+    disable_msvc_warnings(ggml-cpu-sse42)
+    disable_msvc_warnings(ggml-cpu-sandybridge)
+    disable_msvc_warnings(ggml-cpu-haswell)
+    disable_msvc_warnings(ggml-cpu-skylakex)
+    disable_msvc_warnings(ggml-cpu-icelake)
+    disable_msvc_warnings(ggml-cpu-alderlake)
 endif()