From 5d7103af4e6fb6c5055d5b0f82d8f3c2aab24bb8 Mon Sep 17 00:00:00 2001 From: Elias Kosunen Date: Fri, 11 May 2018 19:30:05 +0300 Subject: [PATCH] Enable -Werror on CI Increase warning level on MSVC when compiling with FMT_PEDANTIC --- CMakeLists.txt | 12 ++++++++++++ appveyor.yml | 1 + support/travis-build.py | 4 ++-- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 120000 appveyor.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index 4156356d..9d4418e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,6 +80,8 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU") set(PEDANTIC_COMPILE_FLAGS ${PEDANTIC_COMPILE_FLAGS} -Wshift-overflow=2 -Wnull-dereference -Wduplicated-cond) endif () + + set(WERROR_FLAG -Werror) endif () if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") @@ -87,6 +89,13 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") -Wno-weak-vtables -Wno-padded -Wno-gnu-statement-expression -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-reserved-id-macro -Wno-global-constructors -Wno-disabled-macro-expansion) + + set(WERROR_FLAG -Werror) +endif () + +if (MSVC) + set(PEDANTIC_COMPILE_FLAGS /W4) + set(WERROR_FLAG /WX) endif () if (MASTER_PROJECT AND CMAKE_GENERATOR MATCHES "Visual Studio") @@ -135,6 +144,9 @@ add_library(fmt::fmt ALIAS fmt) # Starting with CMake 3.1 the CXX_STANDARD property can be used instead. # Don't export -std since it may break projects that use other standards. target_compile_options(fmt PRIVATE ${CPP14_FLAG}) +if (FMT_WERROR) + target_compile_options(fmt PRIVATE ${WERROR_FLAG}) +endif () if (FMT_PEDANTIC) target_compile_options(fmt PRIVATE ${PEDANTIC_COMPILE_FLAGS}) endif () diff --git a/appveyor.yml b/appveyor.yml new file mode 120000 index 00000000..a053ea84 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1 @@ +support/appveyor.yml \ No newline at end of file diff --git a/support/travis-build.py b/support/travis-build.py index baefc1d4..ce34b98a 100755 --- a/support/travis-build.py +++ b/support/travis-build.py @@ -86,12 +86,12 @@ test_build_dir = os.path.join(fmt_dir, "_build_test") # Configure library. makedirs_if_not_exist(build_dir) common_cmake_flags = [ - '-DCMAKE_INSTALL_PREFIX=' + install_dir, '-DCMAKE_BUILD_TYPE=' + build + '-DCMAKE_INSTALL_PREFIX=' + install_dir, '-DCMAKE_BUILD_TYPE=' + build, ] extra_cmake_flags = [] if standard != '14': extra_cmake_flags = ['-DCMAKE_CXX_FLAGS=-std=c++' + standard] -check_call(['cmake', '-DFMT_DOC=OFF', '-DFMT_PEDANTIC=ON', fmt_dir] + +check_call(['cmake', '-DFMT_DOC=OFF', '-DFMT_PEDANTIC=ON', '-DFMT_WERROR=ON', fmt_dir] + common_cmake_flags + extra_cmake_flags, cwd=build_dir) # Build library.