From: vanklompf Date: Mon, 4 Dec 2017 22:31:10 +0000 (+0100) Subject: CMake option to treat warnings as errors X-Git-Tag: R_2_2_6~31^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ef64aa331dbdb5946202136ccdb92af981bba36c;p=libexpat CMake option to treat warnings as errors --- diff --git a/appveyor.yml b/appveyor.yml index 7a5f3e37..f52e7871 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -164,7 +164,7 @@ environment: before_build: - echo Running cmake... - cd c:\projects\libexpat - - cmake -G"%GENERATOR%" expat + - cmake -DWARNINGS_AS_ERRORS=ON -G"%GENERATOR%" expat build: parallel: true # enable MSBuild parallel builds diff --git a/expat/CMakeLists.txt b/expat/CMakeLists.txt index 504d087a..43a2e12d 100644 --- a/expat/CMakeLists.txt +++ b/expat/CMakeLists.txt @@ -47,6 +47,7 @@ endif() set(XML_CONTEXT_BYTES 1024 CACHE STRING "Define to specify how much context to retain around the current parse point") option(XML_DTD "Define to make parameter entity parsing functionality available" ON) option(XML_NS "Define to make XML Namespaces functionality available" ON) +option(WARNINGS_AS_ERRORS "Treat all compiler warnings as errors" OFF) if(NOT WIN32) option(XML_DEV_URANDOM "Define to include code reading entropy from `/dev/urandom'." ON) if(XML_DEV_URANDOM) @@ -75,6 +76,13 @@ set(EXTRA_COMPILE_FLAGS) if(FLAG_NO_STRICT_ALIASING) set(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -fno-strict-aliasing") endif() +if (WARNINGS_AS_ERRORS) + if(MSVC) + add_definitions(/WX) + else(MSVC) + set(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -Werror") + endif(MSVC) +endif(WARNINGS_AS_ERRORS) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_COMPILE_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_COMPILE_FLAGS}")