danbev commited on
Commit
a216359
·
unverified ·
1 Parent(s): 1f9c279

whisper : enable compiler warnings for src (#2891)

Browse files

* 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.

Files changed (1) hide show
  1. src/CMakeLists.txt +20 -0
src/CMakeLists.txt CHANGED
@@ -7,6 +7,26 @@ if (WIN32)
7
  endif()
8
  endif()
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  if (WHISPER_COREML)
11
  find_library(FOUNDATION_FRAMEWORK Foundation)
12
  find_library(COREML_FRAMEWORK CoreML)
 
7
  endif()
8
  endif()
9
 
10
+
11
+ if (WHISPER_ALL_WARNINGS)
12
+ if (NOT MSVC)
13
+ list(APPEND WARNING_FLAGS -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function)
14
+ list(APPEND C_FLAGS -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes
15
+ -Werror=implicit-int -Werror=implicit-function-declaration)
16
+ list(APPEND CXX_FLAGS -Wmissing-declarations -Wmissing-noreturn)
17
+
18
+ list(APPEND C_FLAGS ${WARNING_FLAGS})
19
+ list(APPEND CXX_FLAGS ${WARNING_FLAGS})
20
+
21
+ add_compile_options("$<$<COMPILE_LANGUAGE:C>:${C_FLAGS}>"
22
+ "$<$<COMPILE_LANGUAGE:CXX>:${CXX_FLAGS}>")
23
+ else()
24
+ # todo : msvc
25
+ set(C_FLAGS "")
26
+ set(CXX_FLAGS "")
27
+ endif()
28
+ endif()
29
+
30
  if (WHISPER_COREML)
31
  find_library(FOUNDATION_FRAMEWORK Foundation)
32
  find_library(COREML_FRAMEWORK CoreML)