Enable -Werror build for clang on Circle CI
This commit is contained in:
parent
b66b7bfeb1
commit
f4be42d892
@ -377,17 +377,28 @@ jobs:
|
|||||||
BUILD_TYPE: "Release"
|
BUILD_TYPE: "Release"
|
||||||
CMAKE_FLAGS: ""
|
CMAKE_FLAGS: ""
|
||||||
RUN_TESTS: true
|
RUN_TESTS: true
|
||||||
# clang_werror:
|
clang_werror:
|
||||||
# <<: *job_definition
|
<<: *job_definition
|
||||||
# environment:
|
environment:
|
||||||
# CC: clang-7
|
CC: clang-7
|
||||||
# CXX: clang++-7
|
CXX: clang++-7
|
||||||
# BUILD_TOOLSET: clang
|
BUILD_TOOLSET: clang
|
||||||
# APT_COMPILER_PACKAGE: clang-7
|
APT_COMPILER_PACKAGE: clang-7
|
||||||
# CXXFLAGS: "-Werror"
|
CXXFLAGS: ""
|
||||||
# BUILD_TYPE: "Release"
|
BUILD_TYPE: "Release"
|
||||||
# CMAKE_FLAGS: ""
|
CMAKE_FLAGS: "-DUSE_WERROR=on"
|
||||||
# RUN_TESTS: false
|
RUN_TESTS: false
|
||||||
|
gcc_werror:
|
||||||
|
<<: *job_definition
|
||||||
|
environment:
|
||||||
|
CC: gcc-8
|
||||||
|
CXX: g++-8
|
||||||
|
BUILD_TOOLSET: gcc
|
||||||
|
APT_COMPILER_PACKAGE: "g++-8"
|
||||||
|
CXXFLAGS: ""
|
||||||
|
BUILD_TYPE: "Release"
|
||||||
|
CMAKE_FLAGS: "-DUSE_WERROR=on"
|
||||||
|
RUN_TESTS: false
|
||||||
gcc_werror:
|
gcc_werror:
|
||||||
<<: *job_definition
|
<<: *job_definition
|
||||||
environment:
|
environment:
|
||||||
@ -484,8 +495,8 @@ workflows:
|
|||||||
<<: *enable_for_tags
|
<<: *enable_for_tags
|
||||||
- clang_7_release:
|
- clang_7_release:
|
||||||
<<: *enable_for_tags
|
<<: *enable_for_tags
|
||||||
# - clang_werror:
|
- clang_werror:
|
||||||
# <<: *enable_for_tags
|
<<: *enable_for_tags
|
||||||
- gcc_werror:
|
- gcc_werror:
|
||||||
<<: *enable_for_tags
|
<<: *enable_for_tags
|
||||||
- no_compatibility:
|
- no_compatibility:
|
||||||
|
@ -18,9 +18,13 @@ require_clang_version(4.0)
|
|||||||
option(BUILD_TESTING "build test cases" OFF)
|
option(BUILD_TESTING "build test cases" OFF)
|
||||||
option(CRYFS_UPDATE_CHECKS "let cryfs check for updates and security vulnerabilities" ON)
|
option(CRYFS_UPDATE_CHECKS "let cryfs check for updates and security vulnerabilities" ON)
|
||||||
option(DISABLE_OPENMP "allow building without OpenMP libraries. This will cause performance degradations." OFF)
|
option(DISABLE_OPENMP "allow building without OpenMP libraries. This will cause performance degradations." OFF)
|
||||||
|
|
||||||
|
# The following options are helpful for development and/or CI
|
||||||
|
option(USE_WERROR "build with -Werror flag")
|
||||||
option(USE_CLANG_TIDY "build with clang-tidy checks enabled" OFF)
|
option(USE_CLANG_TIDY "build with clang-tidy checks enabled" OFF)
|
||||||
option(CLANG_TIDY_WARNINGS_AS_ERRORS "treat clang-tidy warnings as errors" OFF)
|
option(CLANG_TIDY_WARNINGS_AS_ERRORS "treat clang-tidy warnings as errors" OFF)
|
||||||
|
|
||||||
|
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
option(DOKAN_PATH "Location of the Dokan library, e.g. C:\\Program Files\\Dokan\\DokanLibrary-1.1.0" "")
|
option(DOKAN_PATH "Location of the Dokan library, e.g. C:\\Program Files\\Dokan\\DokanLibrary-1.1.0" "")
|
||||||
endif()
|
endif()
|
||||||
|
@ -56,12 +56,18 @@ endif()
|
|||||||
# Uses: target_enable_style_warnings(buildtarget)
|
# Uses: target_enable_style_warnings(buildtarget)
|
||||||
#################################################
|
#################################################
|
||||||
function(target_enable_style_warnings TARGET)
|
function(target_enable_style_warnings TARGET)
|
||||||
# Enable compiler options
|
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
if (NOT MSVC)
|
# TODO
|
||||||
# TODO Add compiler warnings on MSVC
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang")
|
||||||
|
target_compile_options(${TARGET} PRIVATE -Wall -Wextra -Wold-style-cast -Wcast-align -Wno-unused-command-line-argument) # TODO consider -Wpedantic -Wchkp -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wundef -Wno-unused -Wno-variadic-macros -Wno-parentheses -fdiagnostics-show-option -Wconversion and others?
|
||||||
|
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
||||||
target_compile_options(${TARGET} PRIVATE -Wall -Wextra -Wold-style-cast -Wcast-align) # TODO consider -Wpedantic -Wchkp -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wundef -Wno-unused -Wno-variadic-macros -Wno-parentheses -fdiagnostics-show-option -Wconversion and others?
|
target_compile_options(${TARGET} PRIVATE -Wall -Wextra -Wold-style-cast -Wcast-align) # TODO consider -Wpedantic -Wchkp -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wundef -Wno-unused -Wno-variadic-macros -Wno-parentheses -fdiagnostics-show-option -Wconversion and others?
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (USE_WERROR)
|
||||||
|
target_compile_options(${TARGET} PRIVATE -Werror)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Enable clang-tidy
|
# Enable clang-tidy
|
||||||
if(USE_CLANG_TIDY)
|
if(USE_CLANG_TIDY)
|
||||||
set_target_properties(
|
set_target_properties(
|
||||||
|
@ -97,9 +97,12 @@ namespace {
|
|||||||
}
|
}
|
||||||
void set_handler(int signum, void(*handler)(int)) {
|
void set_handler(int signum, void(*handler)(int)) {
|
||||||
auto result = signal(signum, handler);
|
auto result = signal(signum, handler);
|
||||||
|
#pragma GCC diagnostic push // SIG_ERR uses old style casts
|
||||||
|
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||||
if (SIG_ERR == result) {
|
if (SIG_ERR == result) {
|
||||||
LOG(ERR, "Failed to set signal {} handler. Errno: {}", signum, errno);
|
LOG(ERR, "Failed to set signal {} handler. Errno: {}", signum, errno);
|
||||||
}
|
}
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,11 +57,14 @@ namespace cpputils {
|
|||||||
if (returncode == -1) {
|
if (returncode == -1) {
|
||||||
throw std::runtime_error("Error calling pclose. Errno: " + std::to_string(errno));
|
throw std::runtime_error("Error calling pclose. Errno: " + std::to_string(errno));
|
||||||
}
|
}
|
||||||
|
#pragma GCC diagnostic push // WIFEXITSTATUS / WEXITSTATUS use old style casts
|
||||||
|
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||||
if (!WIFEXITED(returncode)) {
|
if (!WIFEXITED(returncode)) {
|
||||||
// WEXITSTATUS is only valid if WIFEXITED is 0.
|
// WEXITSTATUS is only valid if WIFEXITED is 0.
|
||||||
throw std::runtime_error("WIFEXITED returned " + std::to_string(WIFEXITED(returncode)));
|
throw std::runtime_error("WIFEXITED returned " + std::to_string(WIFEXITED(returncode)));
|
||||||
}
|
}
|
||||||
return WEXITSTATUS(returncode);
|
return WEXITSTATUS(returncode);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
Reference in New Issue
Block a user