diff --git a/.github/ci-test-each-commit-exec.py b/.github/ci-test-each-commit-exec.py index fcd3bbdb546..cdbf4ff438d 100755 --- a/.github/ci-test-each-commit-exec.py +++ b/.github/ci-test-each-commit-exec.py @@ -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", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ed0a77c24fc..8257f565c01 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: diff --git a/CMakeLists.txt b/CMakeLists.txt index 005b1074b59..f992a8d6af4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/ci/test/00_setup_env_native_previous_releases.sh b/ci/test/00_setup_env_native_previous_releases.sh index a44a51c37a4..d6af52c4bf3 100755 --- a/ci/test/00_setup_env_native_previous_releases.sh +++ b/ci/test/00_setup_env_native_previous_releases.sh @@ -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' \ " diff --git a/ci/test/03_test_script.sh b/ci/test/03_test_script.sh index 8d1a739df39..c2117d7e97a 100755 --- a/ci/test/03_test_script.sh +++ b/ci/test/03_test_script.sh @@ -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