diff --git a/CMakeLists.txt b/CMakeLists.txt index c5007b396..700c80a20 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,7 @@ mark_as_advanced( ZM_SYSTEMD ZM_MANPAGE_DEST_PREFIX) +option(ENABLE_WERROR "Fail the build if a compiler warning is emitted" 0) option(BUILD_TEST_SUITE "Build the test suite" 0) option(BUILD_MAN "Build man pages" 1) option(ASAN "DEBUGGING: Build with AddressSanitizer (ASan) support" 0) diff --git a/cmake/compiler/clang/settings.cmake b/cmake/compiler/clang/settings.cmake index 1e5485001..6c5419a94 100644 --- a/cmake/compiler/clang/settings.cmake +++ b/cmake/compiler/clang/settings.cmake @@ -5,6 +5,12 @@ target_compile_options(zm-warning-interface -Wimplicit-fallthrough -Wno-unused-parameter) +if(ENABLE_WERROR) + target_compile_options(zm-warning-interface + INTERFACE + -Werror) +endif() + if(ASAN) target_compile_options(zm-compile-option-interface INTERFACE diff --git a/cmake/compiler/gcc/settings.cmake b/cmake/compiler/gcc/settings.cmake index 741b970ec..097270d51 100644 --- a/cmake/compiler/gcc/settings.cmake +++ b/cmake/compiler/gcc/settings.cmake @@ -9,6 +9,12 @@ target_compile_options(zm-warning-interface -Wno-unused-parameter -Woverloaded-virtual) +if(ENABLE_WERROR) + target_compile_options(zm-warning-interface + INTERFACE + -Werror) +endif() + if(ASAN) target_compile_options(zm-compile-option-interface INTERFACE