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"
5555option (THREADLOCAL "Enable features that depend on the C++ thread_local keyword (currently just thread names in debug logs)." ON )
5656option (HARDENING "Attempt to harden the resulting executables." ON )
5757option (REDUCE_EXPORTS "Attempt to reduce exported symbols in the resulting executables." OFF )
58+ option (WERROR "Treat compiler warnings as errors." OFF )
5859
5960tristate_option(CCACHE "Use ccache for compiling." "if ccache is found." AUTO)
6061tristate_option(WITH_NATPMP "Enable NAT-PMP." "if libnatpmp is found." AUTO)
@@ -285,6 +286,19 @@ if(REDUCE_EXPORTS)
285286 try_append_linker_flag("-Wl,--exclude-libs,ALL" TARGET core)
286287endif ()
287288
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+
288302find_package (Python3 3.9 COMPONENTS Interpreter)
289303set (PYTHON_COMMAND ${Python3_EXECUTABLE} )
290304
@@ -341,6 +355,7 @@ message("Linker flags for shared libraries ..... ${CMAKE_SHARED_LINKER_FLAGS}")
341355print_config_flags()
342356message ("Use assembly routines ................. ${ASM} " )
343357message ("Attempt to harden executables ......... ${HARDENING} " )
358+ message ("Treat compiler warnings as errors ..... ${WERROR} " )
344359message ("Use ccache for compiling .............. ${CCACHE} " )
345360message ("\n " )
346361if (configure_warnings)
You can’t perform that action at this time.
0 commit comments