From: Manuel Nickschas Date: Sun, 18 Nov 2018 20:02:12 +0000 (+0100) Subject: cmake: Allow to make compile warnings fatal X-Git-Tag: test-travis-01~88 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=07c41b7cebcc87a313a5bfccd50a7949d126180a;ds=sidebyside cmake: Allow to make compile warnings fatal Failing on any compile warning is very useful in CI builds, so add an option for enabling this. The option defaults to OFF, because we don't want to annoy users that don't want this. Enable fatal warnings in Travis CI. --- diff --git a/.travis.yml b/.travis.yml index 36b1e2f0..a9976074 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,7 @@ script: -GNinja \ -DCMAKE_BUILD_TYPE=RelWithDebInfo \ -DBUILD_TESTING=ON \ + -DFATAL_WARNINGS=ON \ && ninja install \ && ccache -s \ && ctest -VV \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f4e2356..a27d1a6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,7 @@ if (NOT EMBED_DEFAULT) endif() # The following options are not for end-user consumption, so don't list them in the feature summary +option(FATAL_WARNINGS "Make compile warnings fatal (most useful for CI builds)" OFF) cmake_dependent_option(DEPLOY "Add required libs to bundle resources and create a dmg" OFF "APPLE" OFF) # List of authenticators and the cmake flags to build them diff --git a/cmake/QuasselCompileSettings.cmake b/cmake/QuasselCompileSettings.cmake index 2914f427..2e5d592e 100644 --- a/cmake/QuasselCompileSettings.cmake +++ b/cmake/QuasselCompileSettings.cmake @@ -45,6 +45,7 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") -Wundef -Wvla -Werror=return-type + "$<$:-Werror>" -Wno-unknown-pragmas "$<$>:-U_FORTIFY_SOURCE;-D_FORTIFY_SOURCE=2>" ) @@ -68,7 +69,10 @@ elseif(MSVC) add_definitions(-DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -D_USE_MATH_DEFINES -DNOMINMAX) # Compile options - add_compile_options(/EHsc) + add_compile_options( + /EHsc + "$<$:/WX>" + ) # Increase warning level on MSVC # CMake puts /W3 in CMAKE_CXX_FLAGS which will be appended later, so we need to replace