From 9cea5495892636c808675a189cda190b3c03afbc Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Mon, 9 Aug 2021 21:42:06 +0200 Subject: Add ENABLE_WERROR option --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ff9bf7..33781a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,8 +9,11 @@ endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set (PROJECT_VERSION "0.8.3") set (PACKAGE ${CMAKE_PROJECT_NAME}) + +# Options option(ENABLE_TESTS "Enable all tests and checks" OFF) option(ENABLE_COVERAGE "Enable coverage reports (includes enabling all tests and checks)" OFF) +option(ENABLE_WERROR "Treat all build warnings as errors" OFF) if(ENABLE_COVERAGE) set(ENABLE_TESTS ON) @@ -19,6 +22,11 @@ else() set(CMAKE_BUILD_TYPE "Release") endif() +if(ENABLE_WERROR) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +endif() + ## ## GNU standard installation directories ## @@ -146,3 +154,4 @@ endif () message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}") message(STATUS "Unit tests: ${ENABLE_TESTS}") +message(STATUS "Build with -Werror: ${ENABLE_WERROR}") -- cgit v1.2.3