From d3472e14d912e0083e7f6a39ac5382cfa6239eee Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 17 Jun 2026 15:12:12 -0400 Subject: [PATCH] src/CMakeLists.txt: add CFLAGS="-Werror" only in Debug builds New versions of GCC and Clang often bring fresh warnings that will break old releases when -Werror is in CFLAGS. It's still desirable to have -Werror enabled during development (where you can actually fix any errors that arise), so as a compromise, this commit changes the addition of -Werror to affect only "Debug" builds (this is what's documented in the README.md). Distributions and end users who make release builds with newer compilers will still see the warnings, they just won't be fatal. --- src/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2b6d305..a86e799 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -48,7 +48,10 @@ else(CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") if ((CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.3) OR CMAKE_C_COMPILER_ID MATCHES "Clang") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + # Only enable -Werror for Debug builds, as we cannot predict + # (or retroactively fix) what GCC/clang will warn about in + # the future. + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -Werror") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wpedantic") endif() endif()