Commit 175ab8e7 by Patrick Steinhardt

cmake: add switch to build with -Werror

Add a simple switch to enable building with "-Werror=<warning>" instead
of "-W<warning". Due to the encapsulated `ENABLE_WARNINGS` macro, this
is as simple as adding a new variable "ENABLE_WERROR`, which can be
passed on the command line via `-DENABLE_WERROR=ON`. The variable
defaults to NO to not bother developers in their day to day work.
parent 4a46a8c1
......@@ -49,6 +49,7 @@ OPTION( VALGRIND "Configure build for valgrind" OFF )
OPTION( CURL "Use curl for HTTP if available" ON)
OPTION( USE_EXT_HTTP_PARSER "Use system HTTP_Parser if available" ON)
OPTION( DEBUG_POOL "Enable debug pool allocator" OFF )
OPTION( ENABLE_WERROR "Enable compilation with -Werror" OFF )
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET( USE_ICONV ON )
......@@ -224,11 +225,18 @@ ELSE ()
SET(CMAKE_C_FLAGS "-D_GNU_SOURCE ${CMAKE_C_FLAGS}")
MACRO(ENABLE_WARNINGS flag)
ADD_C_FLAG_IF_SUPPORTED(-W${flag})
IF(ENABLE_WERROR)
ADD_C_FLAG_IF_SUPPORTED(-Werror=${flag})
ELSE()
ADD_C_FLAG_IF_SUPPORTED(-W${flag})
ENDIF()
ENDMACRO()
MACRO(DISABLE_WARNINGS flag)
ADD_C_FLAG_IF_SUPPORTED(-Wno-${flag})
IF(ENABLE_WERROR)
ADD_C_FLAG_IF_SUPPORTED(-Wno-error=${flag})
ENDIF()
ENDMACRO()
ENABLE_WARNINGS(all)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment