From 740bf7f6a1504655d75e0283900384cc5be1b3d3 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 18 Mar 2025 05:19:18 +0100 Subject: [PATCH] whisper : enable compiler warnings for src (#2891) * 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 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ea3161db..527d38b8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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("$<$:${C_FLAGS}>" + "$<$:${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)