Skip to content

Commit 81f1dd8

Browse files
authored
Use CMake's built-in functionality to enable -Werror (or equivalent) (#323)
Avoids having to manage this per compiler here, and gives users an easy way to disable that passing --compile-no-warning-as-error to CMake.
1 parent e15d404 commit 81f1dd8

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

CMakeLists.txt

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ if (NIGIRI_LINT)
3838
include(cmake/clang-tidy.cmake)
3939
endif ()
4040

41+
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
4142
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
4243
set(nigiri-compile-options
4344
-Weverything
@@ -66,20 +67,14 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
6667
-Wno-ctad-maybe-unsupported
6768
-Wno-nrvo
6869
-Wno-thread-safety-negative
69-
-Wno-unused-private-field
70-
-Werror)
70+
-Wno-unused-private-field)
7171
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
72-
set(nigiri-compile-options -Wall -Wextra -Werror)
73-
elseif (MSVC)
74-
set(nigiri-compile-options /WX)
75-
else ()
72+
set(nigiri-compile-options -Wall -Wextra)
73+
elseif (NOT MSVC)
7674
set(nigiri-compile-options
7775
-Wall
7876
-Wextra
7977
-Wno-maybe-uninitialized)
80-
if (NOT CMAKE_CROSSCOMPILING)
81-
set(nigiri-compile-options ${nigiri-compile-options} -Werror)
82-
endif ()
8378
endif ()
8479

8580

0 commit comments

Comments
 (0)