diff --git a/CMakeLists.txt b/CMakeLists.txt index c9129b3c1c6..2881e6de16e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -154,7 +154,8 @@ endif() cmake_dependent_option(WITH_DBUS "Enable DBus support." ON "CMAKE_SYSTEM_NAME STREQUAL \"Linux\" AND BUILD_GUI" OFF) 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) -if(ENABLE_IPC) +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) +if(ENABLE_IPC AND WITH_EXTERNAL_LIBMULTIPROCESS) find_package(Libmultiprocess REQUIRED COMPONENTS Lib) find_package(LibmultiprocessNative REQUIRED COMPONENTS Bin NAMES Libmultiprocess @@ -674,6 +675,16 @@ if(ENABLE_WALLET) endif() message(" external signer ..................... ${ENABLE_EXTERNAL_SIGNER}") message(" ZeroMQ .............................. ${WITH_ZMQ}") +if(ENABLE_IPC) + if (WITH_EXTERNAL_LIBMULTIPROCESS) + set(ipc_status "ON (with external libmultiprocess)") + else() + set(ipc_status ON) + endif() +else() + set(ipc_status OFF) +endif() +message(" IPC ................................. ${ipc_status}") message(" USDT tracing ........................ ${WITH_USDT}") message(" QR code (GUI) ....................... ${WITH_QRENCODE}") message(" DBus (GUI, Linux only) .............. ${WITH_DBUS}") diff --git a/cmake/libmultiprocess.cmake b/cmake/libmultiprocess.cmake new file mode 100644 index 00000000000..2b8e5e31216 --- /dev/null +++ b/cmake/libmultiprocess.cmake @@ -0,0 +1,28 @@ +# Copyright (c) 2025 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://opensource.org/license/mit/. + +function(add_libmultiprocess subdir) + # Set BUILD_TESTING to match BUILD_TESTS. BUILD_TESTING is a standard cmake + # option that controls whether enable_testing() is called, but in the bitcoin + # build a BUILD_TESTS option is used instead. + set(BUILD_TESTING "${BUILD_TESTS}") + add_subdirectory(${subdir} EXCLUDE_FROM_ALL) + # Apply core_interface compile options to libmultiprocess runtime library. + target_link_libraries(multiprocess PUBLIC $) + target_link_libraries(mputil PUBLIC $) + target_link_libraries(mpgen PUBLIC $) + # Mark capproto options as advanced to hide by default from cmake UI + mark_as_advanced(CapnProto_DIR) + mark_as_advanced(CapnProto_capnpc_IMPORTED_LOCATION) + mark_as_advanced(CapnProto_capnp_IMPORTED_LOCATION) + mark_as_advanced(CapnProto_capnp-json_IMPORTED_LOCATION) + mark_as_advanced(CapnProto_capnp-rpc_IMPORTED_LOCATION) + mark_as_advanced(CapnProto_capnp-websocket_IMPORTED_LOCATION) + mark_as_advanced(CapnProto_kj-async_IMPORTED_LOCATION) + mark_as_advanced(CapnProto_kj-gzip_IMPORTED_LOCATION) + mark_as_advanced(CapnProto_kj-http_IMPORTED_LOCATION) + mark_as_advanced(CapnProto_kj_IMPORTED_LOCATION) + mark_as_advanced(CapnProto_kj-test_IMPORTED_LOCATION) + mark_as_advanced(CapnProto_kj-tls_IMPORTED_LOCATION) +endfunction() diff --git a/depends/toolchain.cmake.in b/depends/toolchain.cmake.in index f23fd76c2e6..0a68a35fee0 100644 --- a/depends/toolchain.cmake.in +++ b/depends/toolchain.cmake.in @@ -160,8 +160,10 @@ endif() if("@multiprocess@" STREQUAL "1") set(ENABLE_IPC ON CACHE BOOL "") + set(WITH_EXTERNAL_LIBMULTIPROCESS ON CACHE BOOL "") set(Libmultiprocess_ROOT "${CMAKE_CURRENT_LIST_DIR}" CACHE PATH "") set(LibmultiprocessNative_ROOT "${CMAKE_CURRENT_LIST_DIR}/native" CACHE PATH "") else() set(ENABLE_IPC OFF CACHE BOOL "") + set(WITH_EXTERNAL_LIBMULTIPROCESS OFF CACHE BOOL "") endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b145f830f0d..dac8872080a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -19,6 +19,10 @@ include(../cmake/crc32c.cmake) include(../cmake/leveldb.cmake) include(../cmake/minisketch.cmake) add_subdirectory(univalue) +if (ENABLE_IPC AND NOT WITH_EXTERNAL_LIBMULTIPROCESS) + include(../cmake/libmultiprocess.cmake) + add_libmultiprocess(ipc/libmultiprocess) +endif() #============================= # secp256k1 subtree #=============================