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 @@ -106,6 +106,7 @@ cmake_dependent_option(BUILD_WALLET_TOOL "Build bitcoin-wallet tool." ${BUILD_TE
106
106
107
107
option (ENABLE_HARDENING "Attempt to harden the resulting executables." ON )
108
108
option (REDUCE_EXPORTS "Attempt to reduce exported symbols in the resulting executables." OFF )
109
+ option (WERROR "Treat compiler warnings as errors." OFF )
109
110
option (WITH_CCACHE "Attempt to use ccache for compiling." ON )
110
111
111
112
option (WITH_NATPMP "Enable NAT-PMP." OFF )
@@ -412,6 +413,19 @@ if(REDUCE_EXPORTS)
412
413
try_append_linker_flag ("-Wl,-no_exported_symbols" VAR CMAKE_EXE_LINKER_FLAGS )
413
414
endif ()
414
415
416
+ if (WERROR )
417
+ if (MSVC )
418
+ set (werror_flag "/WX" )
419
+ else ()
420
+ set (werror_flag "-Werror" )
421
+ endif ()
422
+ try_append_cxx_flags (${werror_flag} TARGET core_interface SKIP_LINK RESULT_VAR compiler_supports_werror )
423
+ if (NOT compiler_supports_werror )
424
+ message (FATAL_ERROR "WERROR set but ${werror_flag} is not usable." )
425
+ endif ()
426
+ unset (werror_flag )
427
+ endif ()
428
+
415
429
find_package (Python3 3.9 COMPONENTS Interpreter )
416
430
if (Python3_EXECUTABLE )
417
431
set (PYTHON_COMMAND ${Python3_EXECUTABLE} )
@@ -471,6 +485,7 @@ message("C++ compiler .......................... ${CMAKE_CXX_COMPILER_ID} ${CMAK
471
485
include (FlagsSummary )
472
486
flags_summary ()
473
487
message ("Attempt to harden executables ......... ${ENABLE_HARDENING} " )
488
+ message ("Treat compiler warnings as errors ..... ${WERROR} " )
474
489
message ("Use ccache for compiling .............. ${WITH_CCACHE} " )
475
490
message ("\n " )
476
491
if (configure_warnings )
You can’t perform that action at this time.
0 commit comments