mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-09 02:59:31 +08:00
build: replace WERROR with CMAKE_COMPILE_WARNING_AS_ERROR
-Werror is added to the previous releases job, given it runs on Ubuntu 22.04, which uses an older CMake. `--compile-no-warning-as-error` can be used, if needed, in future, to suppress the `CMAKE_COMPILE_WARNING_AS_ERROR` behaviour from a CI config. CMAKE_COMPILE_WARNING_AS_ERROR was added to CMake in 3.24. See https://cmake.org/cmake/help/latest/prop_tgt/COMPILE_WARNING_AS_ERROR.html. Co-authored-by: willcl-ark <will8clark@gmail.com>
This commit is contained in:
2
.github/ci-test-each-commit-exec.py
vendored
2
.github/ci-test-each-commit-exec.py
vendored
@@ -38,7 +38,7 @@ def main():
|
||||
"-DAPPEND_CXXFLAGS='-O3 -g2'",
|
||||
"-DAPPEND_CFLAGS='-O3 -g2'",
|
||||
"-DCMAKE_BUILD_TYPE=Debug",
|
||||
"-DWERROR=ON",
|
||||
"-DCMAKE_COMPILE_WARNING_AS_ERROR=ON",
|
||||
"--preset=dev-mode",
|
||||
# Tolerate unused member functions in intermediate commits in a pull request
|
||||
"-DCMAKE_CXX_FLAGS=-Wno-error=unused-member-function",
|
||||
|
||||
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@@ -218,10 +218,10 @@ jobs:
|
||||
job-type: [standard, fuzz]
|
||||
include:
|
||||
- job-type: standard
|
||||
generate-options: '-DBUILD_BENCH=ON -DBUILD_KERNEL_LIB=ON -DBUILD_UTIL_CHAINSTATE=ON -DWERROR=ON'
|
||||
generate-options: '-DBUILD_BENCH=ON -DBUILD_KERNEL_LIB=ON -DBUILD_UTIL_CHAINSTATE=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON'
|
||||
job-name: 'Windows native, VS 2022'
|
||||
- job-type: fuzz
|
||||
generate-options: '-DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_MANIFEST_FEATURES="wallet" -DBUILD_GUI=OFF -DWITH_ZMQ=OFF -DBUILD_FOR_FUZZING=ON -DWERROR=ON'
|
||||
generate-options: '-DVCPKG_MANIFEST_NO_DEFAULT_FEATURES=ON -DVCPKG_MANIFEST_FEATURES="wallet" -DBUILD_GUI=OFF -DWITH_ZMQ=OFF -DBUILD_FOR_FUZZING=ON -DCMAKE_COMPILE_WARNING_AS_ERROR=ON'
|
||||
job-name: 'Windows native, fuzz, VS 2022'
|
||||
|
||||
steps:
|
||||
|
||||
@@ -119,7 +119,6 @@ endif()
|
||||
cmake_dependent_option(BUILD_WALLET_TOOL "Build bitcoin-wallet tool." ${BUILD_TESTS} "ENABLE_WALLET" OFF)
|
||||
|
||||
option(REDUCE_EXPORTS "Attempt to reduce exported symbols in the resulting executables." OFF)
|
||||
option(WERROR "Treat compiler warnings as errors." OFF)
|
||||
option(WITH_CCACHE "Attempt to use ccache for compiling." ON)
|
||||
|
||||
option(WITH_ZMQ "Enable ZMQ notifications." OFF)
|
||||
@@ -568,19 +567,6 @@ if(REDUCE_EXPORTS)
|
||||
try_append_linker_flag("-Wl,-no_exported_symbols" VAR CMAKE_EXE_LINKER_FLAGS)
|
||||
endif()
|
||||
|
||||
if(WERROR)
|
||||
if(MSVC)
|
||||
set(werror_flag "/WX")
|
||||
else()
|
||||
set(werror_flag "-Werror")
|
||||
endif()
|
||||
try_append_cxx_flags(${werror_flag} TARGET core_interface SKIP_LINK RESULT_VAR compiler_supports_werror)
|
||||
if(NOT compiler_supports_werror)
|
||||
message(FATAL_ERROR "WERROR set but ${werror_flag} is not usable.")
|
||||
endif()
|
||||
unset(werror_flag)
|
||||
endif()
|
||||
|
||||
# Prefer Unix-style package components over frameworks on macOS.
|
||||
# This improves compatibility with Python version managers.
|
||||
set(Python3_FIND_FRAMEWORK LAST CACHE STRING "")
|
||||
@@ -685,7 +671,7 @@ message("Cross compiling ....................... ${cross_status}")
|
||||
message("C++ compiler .......................... ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}, ${CMAKE_CXX_COMPILER}")
|
||||
include(FlagsSummary)
|
||||
flags_summary()
|
||||
message("Treat compiler warnings as errors ..... ${WERROR}")
|
||||
message("Treat compiler warnings as errors ..... ${CMAKE_COMPILE_WARNING_AS_ERROR}")
|
||||
message("Use ccache for compiling .............. ${WITH_CCACHE}")
|
||||
message("\n")
|
||||
if(configure_warnings)
|
||||
|
||||
@@ -15,13 +15,14 @@ export TEST_RUNNER_EXTRA="--previous-releases --coverage --extended --exclude fe
|
||||
export GOAL="install"
|
||||
export CI_LIMIT_STACK_SIZE=1
|
||||
export DOWNLOAD_PREVIOUS_RELEASES="true"
|
||||
# Use -Werror as the CMake version does not support CMAKE_COMPILE_WARNING_AS_ERROR
|
||||
export BITCOIN_CONFIG="\
|
||||
--preset=dev-mode \
|
||||
-DREDUCE_EXPORTS=ON \
|
||||
-DCMAKE_BUILD_TYPE=Debug \
|
||||
-DCMAKE_C_FLAGS='-funsigned-char' \
|
||||
-DCMAKE_C_FLAGS='-funsigned-char -Werror' \
|
||||
-DCMAKE_C_FLAGS_DEBUG='-g2 -O2' \
|
||||
-DCMAKE_CXX_FLAGS='-funsigned-char' \
|
||||
-DCMAKE_CXX_FLAGS='-funsigned-char -Werror' \
|
||||
-DCMAKE_CXX_FLAGS_DEBUG='-g2 -O2' \
|
||||
-DAPPEND_CPPFLAGS='-DBOOST_MULTI_INDEX_ENABLE_SAFE_MODE' \
|
||||
"
|
||||
|
||||
@@ -81,13 +81,10 @@ if [ "$DOWNLOAD_PREVIOUS_RELEASES" = "true" ]; then
|
||||
test/get_previous_releases.py --target-dir "$PREVIOUS_RELEASES_DIR"
|
||||
fi
|
||||
|
||||
BITCOIN_CONFIG_ALL="-DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON"
|
||||
BITCOIN_CONFIG_ALL="-DCMAKE_COMPILE_WARNING_AS_ERROR=ON -DBUILD_BENCH=ON -DBUILD_FUZZ_BINARY=ON"
|
||||
if [ -z "$NO_DEPENDS" ]; then
|
||||
BITCOIN_CONFIG_ALL="${BITCOIN_CONFIG_ALL} -DCMAKE_TOOLCHAIN_FILE=$DEPENDS_DIR/$HOST/toolchain.cmake"
|
||||
fi
|
||||
if [ -z "$NO_WERROR" ]; then
|
||||
BITCOIN_CONFIG_ALL="${BITCOIN_CONFIG_ALL} -DWERROR=ON"
|
||||
fi
|
||||
|
||||
ccache --zero-stats
|
||||
|
||||
|
||||
Reference in New Issue
Block a user