]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
ggml : suppress Windows compiler warnings (whisper/3075)
authorDaniel Bevenius <redacted>
Tue, 29 Apr 2025 13:47:55 +0000 (15:47 +0200)
committerGeorgi Gerganov <redacted>
Thu, 1 May 2025 17:15:34 +0000 (20:15 +0300)
* whisper: suppress Windows compiler warnings

This commit disables compiler warnings on window using MSVC.

The motivation for these changes is that some compilers generate
warnings for these conversion, for example Windows MSVC, and
there are quite a few of them. This makes it a little difficult to
spot new warnings that may be introduced and also can be difficult
for users/embedders of ggml where these warnings are hard to separate
from their own warnings.

* squash! whisper: suppress Windows compiler warnings

Move ggml related warnings into ggml. This commit also fixes the
indentation and adds a missing whitespace to the if statement.

ggml/CMakeLists.txt

index 61fe15a15f07415f41b57758513a4b930d509b4c..e632af010c76bbe8161040c6ec7919dba04061f2 100644 (file)
@@ -360,3 +360,18 @@ write_basic_package_version_file(
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ggml-config.cmake
               ${CMAKE_CURRENT_BINARY_DIR}/ggml-version.cmake
         DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ggml)
+
+if (MSVC)
+    set(MSVC_WARNING_FLAGS
+        /wd4005  # Macro redefinition
+        /wd4244  # Conversion from one type to another type, possible loss of data
+        /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})
+    endfunction()
+
+    disable_msvc_warnings(ggml-base)
+    disable_msvc_warnings(ggml)
+    disable_msvc_warnings(ggml-cpu)
+endif()