File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,7 @@ cmake_dependent_option(CXX20 "Enable compilation in C++20 mode." OFF "NOT MSVC"
55
55
option (THREADLOCAL "Enable features that depend on the C++ thread_local keyword (currently just thread names in debug logs)." ON )
56
56
option (HARDENING "Attempt to harden the resulting executables." ON )
57
57
option (REDUCE_EXPORTS "Attempt to reduce exported symbols in the resulting executables." OFF )
58
+ option (WERROR "Treat compiler warnings as errors." OFF )
58
59
59
60
tristate_option(CCACHE "Use ccache for compiling." "if ccache is found." AUTO)
60
61
tristate_option(WITH_NATPMP "Enable NAT-PMP." "if libnatpmp is found." AUTO)
@@ -296,6 +297,19 @@ if(REDUCE_EXPORTS)
296
297
try_append_linker_flag("-Wl,--exclude-libs,ALL" TARGET core)
297
298
endif ()
298
299
300
+ if (WERROR)
301
+ if (MSVC )
302
+ set (werror_flag "/WX" )
303
+ else ()
304
+ set (werror_flag "-Werror" )
305
+ endif ()
306
+ try_append_cxx_flags(${werror_flag} TARGET core RESULT_VAR compiler_supports_werror)
307
+ if (NOT compiler_supports_werror)
308
+ message (FATAL_ERROR "WERROR set but ${werror_flag} is not usable." )
309
+ endif ()
310
+ unset (werror_flag)
311
+ endif ()
312
+
299
313
find_package (Python3 3.9 COMPONENTS Interpreter)
300
314
set (PYTHON_COMMAND ${Python3_EXECUTABLE} )
301
315
@@ -352,6 +366,7 @@ message("Linker flags for shared libraries ..... ${CMAKE_SHARED_LINKER_FLAGS}")
352
366
print_config_flags()
353
367
message ("Use assembly routines ................. ${ASM} " )
354
368
message ("Attempt to harden executables ......... ${HARDENING} " )
369
+ message ("Treat compiler warnings as errors ..... ${WERROR} " )
355
370
message ("Use ccache for compiling .............. ${CCACHE} " )
356
371
message ("\n " )
357
372
if (configure_warnings)
You can’t perform that action at this time.
0 commit comments