From c9c152baba1fbd6e2b061b16a5c987a80309caee Mon Sep 17 00:00:00 2001 From: Jakov Smolic Date: Tue, 26 May 2020 16:35:16 +0200 Subject: [PATCH] CMakeLists: add the option to disable Werror https://github.com/warmcat/libwebsockets/pull/1926 Signed-off-by: Jakov Smolic --- CMakeLists.txt | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e817c378d..f95243186 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,11 @@ include(CTest) option(LWS_WITH_DISTRO_RECOMMENDED "Enable features recommended for distro packaging" OFF) option(LWS_FOR_GITOHASHI "Enable features recommended for use with gitohashi" OFF) +# +# Compiler features +# +option(DISABLE_WERROR "Avoid treating compiler warnings as fatal errors" OFF) + # # Major individual features # @@ -637,12 +642,15 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG) set(CMAKE_C_FLAGS "-fanalyzer ${CMAKE_C_FLAGS}" ) endif() - # always warn all and Werror, and generate debug info + # always warn all and generate debug info if (UNIX AND NOT LWS_PLAT_FREERTOS) - set(CMAKE_C_FLAGS "-g -Wall -Wsign-compare -Wstrict-aliasing -Wuninitialized -Werror ${VISIBILITY_FLAG} -Wundef ${GCOV_FLAGS} ${CMAKE_C_FLAGS} ${ASAN_FLAGS}" ) + set(CMAKE_C_FLAGS "-g -Wall -Wsign-compare -Wstrict-aliasing -Wuninitialized ${VISIBILITY_FLAG} -Wundef ${GCOV_FLAGS} ${CMAKE_C_FLAGS} ${ASAN_FLAGS}" ) else() - set(CMAKE_C_FLAGS "-g -Wall -Wsign-compare -Wuninitialized -Werror ${VISIBILITY_FLAG} ${GCOV_FLAGS} ${CMAKE_C_FLAGS}" ) + set(CMAKE_C_FLAGS "-g -Wall -Wsign-compare -Wuninitialized ${VISIBILITY_FLAG} ${GCOV_FLAGS} ${CMAKE_C_FLAGS}" ) endif() + if ("${DISABLE_WERROR}" STREQUAL "OFF") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror") + endif() endif ()