diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0e5f8982..474741f3 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -21,7 +21,7 @@ basic-build-fork: script: - sh build/gitlab-ci cmake "Unix Makefiles" Debug static -basic-build-main: +basic-build: stage: pre-build rules: - if: '$CI_PROJECT_PATH == "libtiff/libtiff"' diff --git a/build/gitlab-ci b/build/gitlab-ci index 6e6c72d1..76852880 100644 --- a/build/gitlab-ci +++ b/build/gitlab-ci @@ -45,7 +45,7 @@ cmake_build() fi mkdir cmake-build cd cmake-build - opts="-Dfatal-warnings=ON" + opts="-Dfatal-warnings=ON -Dextra-warnings=ON -Dcxx-compat-warnings=ON" para3=`echo "$3" | sed 's/./\L&/g'` if [ "$para3" = "static" ]; then opts2="-DBUILD_SHARED_LIBS:BOOL=OFF" @@ -55,7 +55,7 @@ cmake_build() opts2="" fi echo "Running cmake -G "$1" -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install ${opts} ${opts2} .." - cmake -G "$1" -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install -DCMAKE_C_FLAGS="-Wall -Wextra -Werror" -Dcxx-compat-warnings=ON ${opts} ${opts2} .. + cmake -G "$1" -DCMAKE_UNITY_BUILD=ON -DCMAKE_BUILD_TYPE="$2" -DCMAKE_INSTALL_PREFIX=../cmake-install ${opts} ${opts2} .. $COVERITY_BUILD cmake --build . cmake --build . --target install ctest -V diff --git a/build/gitlab-ci-cygwin b/build/gitlab-ci-cygwin index a5d0342d..582c03e9 100644 --- a/build/gitlab-ci-cygwin +++ b/build/gitlab-ci-cygwin @@ -51,7 +51,7 @@ cmake --version gcc --version || { echo "gcc not found in Cygwin"; exit 1; } # Configure CMake options -CMAKE_OPTS="-Dfatal-warnings=ON" +CMAKE_OPTS="-Dfatal-warnings=ON -Dextra-warnings=ON -Dcxx-compat-warnings=ON" CMAKE_OPTS="$CMAKE_OPTS -DCMAKE_UNITY_BUILD=ON" CMAKE_OPTS="$CMAKE_OPTS -DCMAKE_C_FLAGS=-Wall -Wextra -Werror" diff --git a/build/gitlab-ci-mingw b/build/gitlab-ci-mingw index c3300a01..1d7858d0 100644 --- a/build/gitlab-ci-mingw +++ b/build/gitlab-ci-mingw @@ -53,7 +53,7 @@ cmake --version gcc --version || { echo "gcc not found in MinGW"; exit 1; } # Configure CMake options -CMAKE_OPTS="-Dfatal-warnings=ON" +CMAKE_OPTS="-Dfatal-warnings=ON -Dextra-warnings=ON -Dcxx-compat-warnings=ON" CMAKE_OPTS="$CMAKE_OPTS -DCMAKE_UNITY_BUILD=ON" CMAKE_OPTS="$CMAKE_OPTS -DCMAKE_C_FLAGS=-Wall -Wextra -Werror" diff --git a/build/gitlab-ci.ps1 b/build/gitlab-ci.ps1 index 8320da23..075f979f 100644 --- a/build/gitlab-ci.ps1 +++ b/build/gitlab-ci.ps1 @@ -210,7 +210,8 @@ function Invoke-CMakeConfigure { "-DCMAKE_INSTALL_PREFIX=$InstallDir", "-DCMAKE_UNITY_BUILD=ON", "-Dfatal-warnings=ON", - "-Dextra-warnings=ON" + "-Dextra-warnings=ON", + "-Dcxx-compat-warnings=ON" ) # Add vcpkg toolchain if available @@ -235,9 +236,6 @@ function Invoke-CMakeConfigure { $cmakeArgs += "-DBUILD_SHARED_LIBS=ON" } - # Add MSVC-specific warning flags - $cmakeArgs += "-DCMAKE_C_FLAGS=/W4 /WX" - $cmakeArgs += $SourceDir Write-Host "Running: cmake $($cmakeArgs -join ' ')" diff --git a/cmake/CompilerChecks.cmake b/cmake/CompilerChecks.cmake index 71f08127..39b62ef0 100644 --- a/cmake/CompilerChecks.cmake +++ b/cmake/CompilerChecks.cmake @@ -29,9 +29,17 @@ include(CheckCCompilerFlag) # These are annoyingly verbose, produce false positives or don't work # nicely with all supported compiler versions, so are disabled unless -# explicitly enabled. +# explicitly enabled. These warnings are expected to be clean for +# CI builds when combined with fatal-warnings. option(extra-warnings "Enable extra compiler warnings" OFF) +# These are annoyingly verbose, produce false positives or don't work +# nicely with all supported compiler versions, so are disabled unless +# explicitly enabled. Not used in CI builds because it cannot be +# guaranteed that the builds will be warning-free and so cannot be +# combined with fatal-warnings without breaking the builds. +option(broken-warnings "Enable compiler warnings which will warn erroneously or are broken on some platforms" OFF) + # This will cause the compiler to fail when an error occurs. option(fatal-warnings "Compiler warnings are errors" OFF) @@ -71,6 +79,10 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR list(APPEND test_flags -pedantic -Wextra + ) + endif() + if(broken-warnings) + list(APPEND test_flags -Wformat -Wformat-overflow -Wformat-nonliteral