From 01dd32cc4806257256e77a741379179a133af2a5 Mon Sep 17 00:00:00 2001 From: lizzie Date: Wed, 10 Jun 2026 21:52:41 +0000 Subject: [PATCH] [cmake] Add ENABLE_WERROR option Signed-off-by: lizzie --- docs/Options.md | 2 ++ src/CMakeLists.txt | 19 +++++++++++-------- src/audio_core/CMakeLists.txt | 2 +- src/common/CMakeLists.txt | 2 +- src/core/CMakeLists.txt | 2 +- src/hid_core/CMakeLists.txt | 2 +- src/input_common/CMakeLists.txt | 2 +- src/shader_recompiler/CMakeLists.txt | 2 +- src/video_core/CMakeLists.txt | 2 +- 9 files changed, 20 insertions(+), 15 deletions(-) diff --git a/docs/Options.md b/docs/Options.md index bd353b16ca..73a998a032 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -46,6 +46,8 @@ These options control dependencies. - `YUZU_INSTALL_UDEV_RULES` (OFF) Install udev rules to enable hidraw access - Needed for gyroscopes - Only available on Linux +- `ENABLE_DEBUG_TOOLS` (OFF) Enables debugging and development tools, see [tools](../tools/README.md). +- `ENABLE_WERROR` (OFF) Enables warnings as errors (-Werror). ### Flavors diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a6d526c5eb..cd9b1e93c9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -155,12 +155,15 @@ else() $<$:-fno-rtti>) endif() + if (ENABLE_WERROR) + add_compile_options($<$:-Werror>) + endif() add_compile_options( - $<$:-Werror=all> - $<$:-Werror=extra> - $<$:-Werror=missing-declarations> - $<$:-Werror=shadow> - $<$:-Werror=unused> + $<$:-Wall> + $<$:-Wextra> + $<$:-Wmissing-declarations> + $<$:-Wshadow> + $<$:-Wunused> $<$:-Wno-attributes> $<$:-Wno-invalid-offsetof> $<$:-Wno-unused-parameter> @@ -169,9 +172,9 @@ else() if (CXX_CLANG OR CXX_ICC OR CXX_APPLE) # Clang, AppleClang, or Intel C++ if (NOT MSVC) add_compile_options( - $<$:-Werror=shadow-uncaptured-local> - $<$:-Werror=implicit-fallthrough> - $<$:-Werror=type-limits>) + $<$:-Wshadow-uncaptured-local> + $<$:-Wimplicit-fallthrough> + $<$:-Wtype-limits>) endif() add_compile_options( $<$:-Wno-braced-scalar-init> diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index 4d0b130afc..b186edaab4 100644 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt @@ -222,7 +222,7 @@ if (MSVC) ) else() target_compile_options(audio_core PRIVATE - $<$:-Werror=conversion> + $<$:-Wconversion> $<$:-Wno-sign-conversion>) endif() diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 786effa6bd..c18b303098 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -221,7 +221,7 @@ endif() if(CXX_CLANG) target_compile_options(common PRIVATE $<$:-fsized-deallocation> - $<$:-Werror=unreachable-code-aggressive>) + $<$:-Wunreachable-code-aggressive>) target_compile_definitions( common PRIVATE diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 16806ff0c0..8e01a67c20 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -1199,7 +1199,7 @@ if (MSVC) ) else() target_compile_options(core PRIVATE - $<$:-Werror=conversion> + $<$:-Wconversion> $<$:-Wno-sign-conversion> $<$:-Wno-cast-function-type> $<$:-fsized-deallocation>) diff --git a/src/hid_core/CMakeLists.txt b/src/hid_core/CMakeLists.txt index c740cdbe7f..e617160834 100644 --- a/src/hid_core/CMakeLists.txt +++ b/src/hid_core/CMakeLists.txt @@ -151,7 +151,7 @@ if (MSVC) ) else() target_compile_options(hid_core PRIVATE - $<$:-Werror=conversion> + $<$:-Wconversion> $<$:-Wno-sign-conversion> $<$:-Wno-cast-function-type> $<$:-fsized-deallocation>) diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index 91dd8558ab..840602f4ce 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt @@ -44,7 +44,7 @@ if (MSVC) /we4800 # Implicit conversion from 'type' to bool. Possible information loss ) else() - target_compile_options(input_common PRIVATE $<$:-Werror=conversion>) + target_compile_options(input_common PRIVATE $<$:-Wconversion>) endif() if (ANDROID) diff --git a/src/shader_recompiler/CMakeLists.txt b/src/shader_recompiler/CMakeLists.txt index d02ee268f0..1e6a4d173a 100644 --- a/src/shader_recompiler/CMakeLists.txt +++ b/src/shader_recompiler/CMakeLists.txt @@ -253,7 +253,7 @@ if (MSVC) ) else() target_compile_options(shader_recompiler PRIVATE - $<$:-Werror=conversion> + $<$:-Wconversion> # Bracket depth determines maximum size of a fold expression in Clang since 9c9974c3ccb6. # And this in turns limits the size of a std::array. $<$:-fbracket-depth=1024> diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 53b0d1638b..ab51b71105 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -371,7 +371,7 @@ else() $<$:-Wno-shadow> $<$:-Wno-unused-local-typedef>) else() - target_compile_options(video_core PRIVATE $<$:-Werror=conversion>) + target_compile_options(video_core PRIVATE $<$:-Wconversion>) endif() target_compile_options(video_core PRIVATE $<$:-Wno-sign-conversion>)