Skip to content

Commit 7d5a6d1

Browse files
committed
Merge bitcoin/bitcoin#32798: build: add root dir to CMAKE_PREFIX_PATH in toolchain
e27a945 build: add root dir to CMAKE_PREFIX_PATH (will) Pull request description: Fixes: #32428 Nix patches `cmake` to remove the root directory `/` from `CMAKE_PREFIX_PATH`: https://github.com/NixOS/nixpkgs/blob/428b49b28ebc8938a6d9f6c540d32d7a06713972/pkgs/by-name/cm/cmake/001-search-path.diff#L10 Without this, and when using the toolchain for depends builds, cmake's `find_path()` and `find_package()` do not know where to find dependencies, causing issues like as seen in #32428 Adding this path back is harmless on other systems, and fixes the toolchain for Nix users. As described in bitcoin/bitcoin#32428 (comment) I think this can be taken as a temporary fix whilst a longer-term solution is worked on. ACKs for top commit: josibake: reACK bitcoin/bitcoin@e27a945 hebasto: ACK e27a945, I have reviewed the code and it looks OK. janb84: reACK e27a945 Tree-SHA512: f299f2bab2620179518da866cbb7992d41d142ad42e79c14496e72f725a1dc60698b3e4b1daf45d28f71f32a23f0c8d7b4f6c6cf33aeedf322b7ef565b70b4af
2 parents ad654a4 + e27a945 commit 7d5a6d1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

depends/toolchain.cmake.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,22 @@ set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
9292
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
9393
set(QT_TRANSLATIONS_DIR "${CMAKE_CURRENT_LIST_DIR}/translations")
9494

95+
# The following is only necessary when using cmake from Nix or NixOS, because
96+
# Nix patches cmake to remove the root directory `/` from
97+
# CMAKE_SYSTEM_PREFIX_PATH. Adding it back is harmless on other platforms and
98+
# necessary on Nix because without it cmake find_path, find_package, etc
99+
# functions do not know where to look in CMAKE_FIND_ROOT_PATH for dependencies
100+
# (https://github.com/bitcoin/bitcoin/issues/32428).
101+
#
102+
# TODO: longer term, it may be possible to use a dependency provider, which
103+
# would bring the find_package calls completely under our control, making this
104+
# patch unnecessary.
105+
#
106+
# Make sure we only append once, as this file may be called repeatedly.
107+
if(NOT "/" IN_LIST CMAKE_PREFIX_PATH)
108+
list(APPEND CMAKE_PREFIX_PATH "/")
109+
endif()
110+
95111
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND NOT CMAKE_HOST_APPLE)
96112
# The find_package(Qt ...) function internally uses find_library()
97113
# calls for all dependencies to ensure their availability.

0 commit comments

Comments
 (0)