]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
whisper : enable compiler warnings for src (#2891)
authorDaniel Bevenius <redacted>
Tue, 18 Mar 2025 04:19:18 +0000 (05:19 +0100)
committerGitHub <redacted>
Tue, 18 Mar 2025 04:19:18 +0000 (05:19 +0100)
* whisper : enable compiler warnings for src

This commit enables compiler warnings for the src directory. Currently
when the WHISPER_ALL_WARNINGS flag is set to ON is only enables warnings
in ggml, by setting GGML_ALL_WARNINGS to ON. This commit adds the same
compiler flags for whisper's src directory.

The motivation for this is to catch potential bugs and issues early on
in the development process.

* squash! whisper : enable compiler warnings for src

Remove GF_C_FLAGS and GF_CXX_FLAGS from add_compile_options.

src/CMakeLists.txt

index ea3161dbdab9cfcd7e5f993a77bcd5c7264a1512..527d38b8ce1910075fc6036b7ac540e8f3079fd3 100644 (file)
@@ -7,6 +7,26 @@ if (WIN32)
     endif()
 endif()
 
+
+if (WHISPER_ALL_WARNINGS)
+    if (NOT MSVC)
+        list(APPEND WARNING_FLAGS -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function)
+        list(APPEND C_FLAGS       -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes
+                                  -Werror=implicit-int -Werror=implicit-function-declaration)
+        list(APPEND CXX_FLAGS     -Wmissing-declarations -Wmissing-noreturn)
+
+        list(APPEND C_FLAGS   ${WARNING_FLAGS})
+        list(APPEND CXX_FLAGS ${WARNING_FLAGS})
+
+        add_compile_options("$<$<COMPILE_LANGUAGE:C>:${C_FLAGS}>"
+                            "$<$<COMPILE_LANGUAGE:CXX>:${CXX_FLAGS}>")
+    else()
+        # todo : msvc
+        set(C_FLAGS   "")
+        set(CXX_FLAGS "")
+    endif()
+endif()
+
 if (WHISPER_COREML)
     find_library(FOUNDATION_FRAMEWORK Foundation)
     find_library(COREML_FRAMEWORK CoreML)