This pull request addresses [issue #31057](https://github.com/bitcoin/bitcoin/issues/31057).
Build System:
- Modified
CMakeLists.txtto prevent building the fuzz binary unlessBUILD_FOR_FUZZINGis enabled. - Added a fatal error message if an attempt is made to build the fuzz binary without
BUILD_FOR_FUZZING.
Building the fuzz binary without -DBUILD_FOR_FUZZING results in a binary that is less effective for testing because it won’t crash on Assume statements and won’t bypass fuzz blockers with FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION.
By enforcing -DBUILD_FOR_FUZZING, we ensure that:
- The fuzz binary is correctly configured for fuzz testing.
- Compile failures are caught early in the CI on all platforms.
- Workarounds like #31028 are no longer necessary.