bitcoin/cmake/module
merge-script da3ed8b970
Merge bitcoin/bitcoin#31662: cmake: Do not modify CMAKE_TRY_COMPILE_TARGET_TYPE globally
2c4b229c90 cmake: Introduce `FUZZ_LIBS` (Hennadii Stepanov)
ea929c0848 scripted-diff: Rename CMake helper module (Hennadii Stepanov)
8d238c1dfd cmake: Delete `check_cxx_source_links*` macros (Hennadii Stepanov)
71bf8294a9 cmake: Convert `check_cxx_source_compiles_with_flags` to a function (Hennadii Stepanov)
88ee6800c9 cmake: Delete `check_cxx_source_links_with_flags` macro (Hennadii Stepanov)
09e8fd25b1 build: Don't override CMake's default try_compile target (Hennadii Stepanov)

Pull request description:

  This was requested in https://github.com/bitcoin/bitcoin/pull/31359#issuecomment-2515287092.

  From https://github.com/bitcoin/bitcoin/pull/31359#issuecomment-2511246212:
  > (Almost?) every CMake check internally uses the [`try_compile()`](https://cmake.org/cmake/help/latest/command/try_compile.html) command, whose behaviour, in turn, depends on the [`CMAKE_TRY_COMPILE_TARGET_TYPE`](https://cmake.org/cmake/help/latest/variable/CMAKE_TRY_COMPILE_TARGET_TYPE.html) variable:
  >
  >    1. The default value, `EXECUTABLE`, enables both compiler and linker checks.
  >
  >    2. The `STATIC_LIBRARY` value enables only compiler checks.
  >
  >
  > To mimic Autotools' behaviour, we [disabled](d3f42fa08f/cmake/module/CheckSourceCompilesAndLinks.cmake (L9-L10)) linker checks by setting `CMAKE_TRY_COMPILE_TARGET_TYPE` to `STATIC_LIBRARY` globally (perhaps not the best design). This effectively separates the entire CMake script into regions where `CMAKE_TRY_COMPILE_TARGET_TYPE` is:
  >
  >    * unset
  >
  >    * set to `STATIC_LIBRARY`
  >
  >    * set to `EXECUTABLE`

  From https://github.com/bitcoin/bitcoin/pull/31359#issuecomment-2515287092:
  > > This seems very fragile and unintuitive, and the fact that this could silently break at any point is not documented in any way. I don't think other bad design decisions should lead to us having to write even more boilerplate code to fix things that should "just work" (minus the upstream bugs).
  >
  > Agreed. I forgot that we set `CMAKE_TRY_COMPILE_TARGET_TYPE` globally. And even worse, it's buried in a module. If that upsets CMake internal tests, I think we should undo that.

  This PR ensures that `CMAKE_TRY_COMPILE_TARGET_TYPE` is modified only within local scopes.

  Additionally, the `FUZZ_LIBS` variable has been introduced to handle additional libraries required for linking, rather than link options, in certain build environment, such as OSS-Fuzz.

ACKs for top commit:
  TheCharlatan:
    Re-ACK 2c4b229c90
  theuni:
    utACK 2c4b229c90

Tree-SHA512: f72ffa8f50f216fc1a2f8027ba8ddfd4acd42b94ff6c1cb2138f2da51eb8f945660e97d3c247d7f3f7ec8dfebbccec3ab84347d6ae2e3f8a40f3d7aa8b14cde9
2025-02-20 15:07:03 -05:00
..
AddBoostIfNeeded.cmake cmake: scope Boost Test check to vcpkg 2024-09-05 16:15:27 +01:00
AddWindowsResources.cmake cmake: Add AddWindowsResources module 2024-08-16 21:19:11 +01:00
CheckLinkerSupportsPIE.cmake cmake: Refer to the configure log instead of printing PIE test error 2025-01-23 15:38:36 +00:00
CheckSourceCompilesWithFlags.cmake scripted-diff: Rename CMake helper module 2025-02-20 12:39:20 +00:00
FindBerkeleyDB.cmake cmake: Add wallet functionality 2024-08-16 19:27:40 +01:00
FindLibevent.cmake cmake, refactor: Move HAVE_EVHTTP_... to libevent interface 2024-11-06 15:40:42 +00:00
FindQRencode.cmake cmake: Add FindQRencode module 2024-11-05 16:38:19 +00:00
FindQt.cmake cmake: Avoid hardcoding Qt's major version in Find module 2024-10-01 13:43:30 +01:00
FindUSDT.cmake tracing: dedup TRACE macros & rename to TRACEPOINT 2024-10-28 14:23:47 +01:00
FindZeroMQ.cmake cmake: Add FindZeroMQ module 2024-10-25 18:09:36 +01:00
FlagsSummary.cmake build: Print CMAKE_CXX_COMPILER_ARG1 in summary 2024-09-06 21:59:52 +01:00
GenerateHeaders.cmake build: avoid unnecessary dependencies on generated headers 2025-01-31 15:07:23 +00:00
GenerateSetupNsi.cmake build: Rename PACKAGE_* variables to CLIENT_* 2024-10-28 12:35:55 +00:00
GetTargetInterface.cmake cmake: Print compiler and linker flags in summary 2024-08-16 19:27:36 +01:00
InstallBinaryComponent.cmake cmake: add and use install_binary_component 2025-02-13 18:14:41 +00:00
Maintenance.cmake build: remove ENABLE_HARDENING cond from check-security 2025-02-17 16:35:28 +00:00
ProcessConfigurations.cmake build: set build type and per-build-type flags as early as possible 2025-02-10 21:51:22 +00:00
TestAppendRequiredLibraries.cmake scripted-diff: Rename CMake helper module 2025-02-20 12:39:20 +00:00
TryAppendCXXFlags.cmake cmake: Fix IF_CHECK_PASSED option handling 2024-11-06 08:59:15 +00:00
TryAppendLinkerFlag.cmake cmake: Fix IF_CHECK_PASSED option handling 2024-11-06 08:59:15 +00:00
WarnAboutGlobalProperties.cmake cmake: Introduce interface libraries to encapsulate common flags 2024-08-16 19:27:34 +01:00