Skip to content

Commit d597ab1

Browse files
ryanofskytheunihebasto
committed
cmake: Support building with libmultiprocess subtree
When ENABLE_IPC option is on, build with libmultiprocess subtree and `add_subdirectory(src/ipc/libmultiprocess)` instead of external package and `find_package(Libmultiprocess)` by default. Behavior can be toggled with `WITH_EXTERNAL_LIBMULTIPROCESS` option. Using a subtree should be more convenient for most bitcoin developers, but using an external package is more convenient for developing in the libmultiprocess repository. The `WITH_EXTERNAL_LIBMULTIPROCESS` option is also used to avoid needing to changing the depends build here. But in later commits, the depends build is switched to use the add_subdirectory build as well. Co-authored-by: Cory Fields <[email protected]> Co-authored-by: Hennadii Stepanov <[email protected]>
1 parent 69f0d4a commit d597ab1

File tree

4 files changed

+46
-1
lines changed

4 files changed

+46
-1
lines changed

CMakeLists.txt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ endif()
154154
cmake_dependent_option(WITH_DBUS "Enable DBus support." ON "CMAKE_SYSTEM_NAME STREQUAL \"Linux\" AND BUILD_GUI" OFF)
155155

156156
option(ENABLE_IPC "Build multiprocess bitcoin-node and bitcoin-gui executables in addition to monolithic bitcoind and bitcoin-qt executables. Requires libmultiprocess library. Experimental." OFF)
157-
if(ENABLE_IPC)
157+
cmake_dependent_option(WITH_EXTERNAL_LIBMULTIPROCESS "Build with external libmultiprocess library instead of with local git subtree when ENABLE_IPC is enabled. This is not normally recommended, but can be useful when cross-compiling or making changes to the upstream project." OFF "ENABLE_IPC" OFF)
158+
if(ENABLE_IPC AND WITH_EXTERNAL_LIBMULTIPROCESS)
158159
find_package(Libmultiprocess REQUIRED COMPONENTS Lib)
159160
find_package(LibmultiprocessNative REQUIRED COMPONENTS Bin
160161
NAMES Libmultiprocess
@@ -674,6 +675,16 @@ if(ENABLE_WALLET)
674675
endif()
675676
message(" external signer ..................... ${ENABLE_EXTERNAL_SIGNER}")
676677
message(" ZeroMQ .............................. ${WITH_ZMQ}")
678+
if(ENABLE_IPC)
679+
if (WITH_EXTERNAL_LIBMULTIPROCESS)
680+
set(ipc_status "ON (with external libmultiprocess)")
681+
else()
682+
set(ipc_status ON)
683+
endif()
684+
else()
685+
set(ipc_status OFF)
686+
endif()
687+
message(" IPC ................................. ${ipc_status}")
677688
message(" USDT tracing ........................ ${WITH_USDT}")
678689
message(" QR code (GUI) ....................... ${WITH_QRENCODE}")
679690
message(" DBus (GUI, Linux only) .............. ${WITH_DBUS}")

cmake/libmultiprocess.cmake

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2025 The Bitcoin Core developers
2+
# Distributed under the MIT software license, see the accompanying
3+
# file COPYING or https://opensource.org/license/mit/.
4+
5+
function(add_libmultiprocess subdir)
6+
# Set BUILD_TESTING to match BUILD_TESTS. BUILD_TESTING is a standard cmake
7+
# option that controls whether enable_testing() is called, but in the bitcoin
8+
# build a BUILD_TESTS option is used instead.
9+
set(BUILD_TESTING "${BUILD_TESTS}")
10+
add_subdirectory(${subdir} EXCLUDE_FROM_ALL)
11+
# Apply core_interface compile options to libmultiprocess runtime library.
12+
target_link_libraries(multiprocess PUBLIC $<BUILD_INTERFACE:core_interface>)
13+
target_link_libraries(mputil PUBLIC $<BUILD_INTERFACE:core_interface>)
14+
target_link_libraries(mpgen PUBLIC $<BUILD_INTERFACE:core_interface>)
15+
# Mark capproto options as advanced to hide by default from cmake UI
16+
mark_as_advanced(CapnProto_DIR)
17+
mark_as_advanced(CapnProto_capnpc_IMPORTED_LOCATION)
18+
mark_as_advanced(CapnProto_capnp_IMPORTED_LOCATION)
19+
mark_as_advanced(CapnProto_capnp-json_IMPORTED_LOCATION)
20+
mark_as_advanced(CapnProto_capnp-rpc_IMPORTED_LOCATION)
21+
mark_as_advanced(CapnProto_capnp-websocket_IMPORTED_LOCATION)
22+
mark_as_advanced(CapnProto_kj-async_IMPORTED_LOCATION)
23+
mark_as_advanced(CapnProto_kj-gzip_IMPORTED_LOCATION)
24+
mark_as_advanced(CapnProto_kj-http_IMPORTED_LOCATION)
25+
mark_as_advanced(CapnProto_kj_IMPORTED_LOCATION)
26+
mark_as_advanced(CapnProto_kj-test_IMPORTED_LOCATION)
27+
mark_as_advanced(CapnProto_kj-tls_IMPORTED_LOCATION)
28+
endfunction()

depends/toolchain.cmake.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,10 @@ endif()
160160

161161
if("@multiprocess@" STREQUAL "1")
162162
set(ENABLE_IPC ON CACHE BOOL "")
163+
set(WITH_EXTERNAL_LIBMULTIPROCESS ON CACHE BOOL "")
163164
set(Libmultiprocess_ROOT "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "")
164165
set(LibmultiprocessNative_ROOT "${CMAKE_CURRENT_LIST_DIR}/native" CACHE PATH "")
165166
else()
166167
set(ENABLE_IPC OFF CACHE BOOL "")
168+
set(WITH_EXTERNAL_LIBMULTIPROCESS OFF CACHE BOOL "")
167169
endif()

src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ include(../cmake/crc32c.cmake)
1919
include(../cmake/leveldb.cmake)
2020
include(../cmake/minisketch.cmake)
2121
add_subdirectory(univalue)
22+
if (ENABLE_IPC AND NOT WITH_EXTERNAL_LIBMULTIPROCESS)
23+
include(../cmake/libmultiprocess.cmake)
24+
add_libmultiprocess(ipc/libmultiprocess)
25+
endif()
2226
#=============================
2327
# secp256k1 subtree
2428
#=============================

0 commit comments

Comments
 (0)