Merge bitcoin/bitcoin#34591: cmake: Improve install_name_tool workaround

38a7a6712663b52a40210374334c7427bc776cf4 cmake: Provide `install_name_tool` stub instead of disabling it (Hennadii Stepanov)
80dc4359b8a1580341c22a91d4fc42daa6ce10eb cmake: Apply workaround for `install_name_tool` conditionally (Hennadii Stepanov)

Pull request description:

  We stopped using `install_name_tool` in 3bee51427a05075150721f0a05ead8f92e1ba019 (https://github.com/bitcoin/bitcoin/pull/29890), which [required](https://github.com/hebasto/bitcoin/pull/180) a CMake-specific hack:b65ff0e5a1/CMakeLists.txt (L72-L76)

  Due to recent changes in CMake, this hack has become problematic for the following reasons:
  1. It is no longer needed when using CMake 4.2 or newer. See upstream [Issue #27069](https://gitlab.kitware.com/cmake/cmake/-/issues/27069) and [MR #10955](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/10955).

  2. It causes an [issue](https://github.com/bitcoin/bitcoin/issues/34513) when using CMake 4.0.5 or newer. See upstream [Issue #26814](https://gitlab.kitware.com/cmake/cmake/-/issues/26814) and [MR #10721](https://gitlab.kitware.com/cmake/cmake/-/merge_requests/10721).

  This PR addresses both of these issues. Please see the individual commits for more details.

  Fixes https://github.com/bitcoin/bitcoin/issues/34513.

ACKs for top commit:
  fanquake:
    ACK 38a7a6712663b52a40210374334c7427bc776cf4

Tree-SHA512: 7a11aa5b7f72034c798f20043ae89aa6c125bf5adf9c808a469aa30c2a56ad0a7aaf69919cb40a9eec08e029915890685968a9b7d5998e1337810f9cd2f6caf2
This commit is contained in:
merge-script 2026-03-05 11:29:54 +00:00
commit 69b2c813f0
No known key found for this signature in database
GPG Key ID: 2EEB9F5CC09526C1

View File

@ -69,10 +69,15 @@ set(CLIENT_BUGREPORT "https://github.com/bitcoin/bitcoin/issues")
#=============================
# Language setup
#=============================
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
if(CMAKE_VERSION VERSION_LESS 4.2 AND CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
# We do not use the install_name_tool when cross-compiling for macOS.
# However, CMake < 4.2 still searches for Apple's version of the tool,
# which causes an error during configuration.
# See:
# - https://gitlab.kitware.com/cmake/cmake/-/issues/27069
# - https://gitlab.kitware.com/cmake/cmake/-/merge_requests/10955
# So disable this tool check in further enable_language() commands.
set(CMAKE_PLATFORM_HAS_INSTALLNAME FALSE)
set(CMAKE_INSTALL_NAME_TOOL "${CMAKE_COMMAND} -E true")
endif()
enable_language(CXX)
set(CMAKE_CXX_STANDARD 20)