bitcoin/cmake
Ryan Ofsky 1b4ddb0c2d
Merge bitcoin/bitcoin#32356: cmake: Respect user-provided configuration-specific flags
edde96376a cmake: Respect user-provided configuration-specific flags (Hennadii Stepanov)

Pull request description:

  This PR addresses [this](https://github.com/bitcoin/bitcoin/issues/31491#issuecomment-2542140874) comment:
  > I suppose that should only happen if the `-O3` isn't coming from an explicitly set `CMAKE_CXX_FLAGS_RELEASE`.

  With this PR:
  ```
  $ cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS_RELEASE="-O3"
  <snip>
  C++ compiler flags .................... -O3 -std=c++20 -fPIC -fno-extended-identifiers -fdebug-prefix-map=/home/hebasto/dev/bitcoin/src=. -fmacro-prefix-map=/home/hebasto/dev/bitcoin/src=. -fstack-reuse=none -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wbidi-chars=any -Wundef -Wno-unused-parameter -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection
  Linker flags .......................... -O3 -fstack-reuse=none -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fPIE -pie
  ```
  and
  ```
  $ cmake -B build -DCMAKE_BUILD_TYPE=Release
  <snip>
  C++ compiler flags .................... -O2 -std=c++20 -fPIC -fno-extended-identifiers -fdebug-prefix-map=/home/hebasto/dev/bitcoin/src=. -fmacro-prefix-map=/home/hebasto/dev/bitcoin/src=. -fstack-reuse=none -Wall -Wextra -Wformat -Wformat-security -Wvla -Wredundant-decls -Wdate-time -Wduplicated-branches -Wduplicated-cond -Wlogical-op -Woverloaded-virtual -Wsuggest-override -Wimplicit-fallthrough -Wunreachable-code -Wbidi-chars=any -Wundef -Wno-unused-parameter -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -Wstack-protector -fstack-protector-all -fcf-protection=full -fstack-clash-protection
  Linker flags .......................... -O2 -fstack-reuse=none -fstack-protector-all -fcf-protection=full -fstack-clash-protection -Wl,-z,relro -Wl,-z,now -Wl,-z,separate-code -fPIE -pie
  ```

  When calling `cmake` repeatedly using the same build directory, each newly provided `CMAKE_CXX_FLAGS_RELEASE` value will be accommodated. In such a scenario, if the user wishes to revert to the build system defaults, they should unset the `CMAKE_CXX_FLAGS_RELEASE` variable by passing `-UCMAKE_CXX_FLAGS_RELEASE`  to `cmake`.

  ---

  This PR does not aim to resolve _all_ issues mentioned in https://github.com/bitcoin/bitcoin/issues/31491.

ACKs for top commit:
  purpleKarrot:
    ACK edde96376a
  janb84:
    ACK [edde963](edde96376a)
  ryanofsky:
    Code review ACK edde96376a

Tree-SHA512: 1fbc879bd02cf0be726ced490f65985e728f0686ccb3a32cd38787b56377aa666e1965448e5069515abc814df49a0083c8000bc3f6f322f5f395695638168fb6
2025-05-08 11:06:13 -04:00
..
module Merge bitcoin/bitcoin#32356: cmake: Respect user-provided configuration-specific flags 2025-05-08 11:06:13 -04:00
script cmake: Copy cov_tool_wrapper.sh.in to the build tree 2025-01-23 10:00:58 +00:00
bitcoin-build-config.h.in build, wallet, doc: Remove BDB 2025-05-06 12:21:32 -07:00
ccache.cmake build: don't use ccache with MSVC 2025-03-04 14:53:06 +00:00
crc32c.cmake Merge bitcoin/bitcoin#31662: cmake: Do not modify CMAKE_TRY_COMPILE_TARGET_TYPE globally 2025-02-20 15:07:03 -05:00
introspection.cmake build: replace header checks with __has_include 2025-05-02 16:41:04 +01:00
leveldb.cmake Merge bitcoin/bitcoin#31366: cmake: Check -Wno-* compiler options for leveldb target 2025-02-20 12:22:20 -05:00
libmultiprocess.cmake cmake: Fix clang-tidy "no input files" errors 2025-04-02 08:41:16 -05:00
minisketch.cmake Merge bitcoin/bitcoin#31880: cmake: Add optional sources to minisketch library directly 2025-02-25 14:11:58 -05:00
tests.cmake cmake: Add Python-based tests 2024-08-16 19:27:41 +01:00