File tree 1 file changed +15
-0
lines changed
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)
@@ -285,6 +286,19 @@ if(REDUCE_EXPORTS)
285
286
try_append_linker_flag("-Wl,--exclude-libs,ALL" TARGET core)
286
287
endif ()
287
288
289
+ if (WERROR)
290
+ if (MSVC )
291
+ set (werror_flag "/WX" )
292
+ else ()
293
+ set (werror_flag "-Werror" )
294
+ endif ()
295
+ try_append_cxx_flags(${werror_flag} TARGET core RESULT_VAR compiler_supports_werror)
296
+ if (NOT compiler_supports_werror)
297
+ message (FATAL_ERROR "WERROR set but ${werror_flag} is not usable." )
298
+ endif ()
299
+ unset (werror_flag)
300
+ endif ()
301
+
288
302
find_package (Python3 3.9 COMPONENTS Interpreter)
289
303
set (PYTHON_COMMAND ${Python3_EXECUTABLE} )
290
304
@@ -341,6 +355,7 @@ message("Linker flags for shared libraries ..... ${CMAKE_SHARED_LINKER_FLAGS}")
341
355
print_config_flags()
342
356
message ("Use assembly routines ................. ${ASM} " )
343
357
message ("Attempt to harden executables ......... ${HARDENING} " )
358
+ message ("Treat compiler warnings as errors ..... ${WERROR} " )
344
359
message ("Use ccache for compiling .............. ${CCACHE} " )
345
360
message ("\n " )
346
361
if (configure_warnings)
You can’t perform that action at this time.
0 commit comments