diff --git a/CMakeLists.txt b/CMakeLists.txt index 993f59915a1..814ed10684e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -155,6 +155,15 @@ if(WITH_QRENCODE) endif() cmake_dependent_option(WITH_DBUS "Enable DBus support." ON "CMAKE_SYSTEM_NAME STREQUAL \"Linux\" AND BUILD_GUI" OFF) + +option(WITH_MULTIPROCESS "Build multiprocess bitcoin-node and bitcoin-gui executables in addition to monolithic bitcoind and bitcoin-qt executables. Requires libmultiprocess library. Experimental." OFF) +if(WITH_MULTIPROCESS) + find_package(Libmultiprocess COMPONENTS Lib) + find_package(LibmultiprocessNative COMPONENTS Bin + NAMES Libmultiprocess + ) +endif() + cmake_dependent_option(BUILD_GUI_TESTS "Build test_bitcoin-qt executable." ON "BUILD_GUI;BUILD_TESTS" OFF) if(BUILD_GUI) set(qt_components Core Gui Widgets LinguistTools) @@ -495,7 +504,14 @@ message("Configure summary") message("=================") message("Executables:") message(" bitcoind ............................ ${BUILD_DAEMON}") +message(" bitcoin-node (multiprocess) ......... ${WITH_MULTIPROCESS}") message(" bitcoin-qt (GUI) .................... ${BUILD_GUI}") +if(BUILD_GUI AND WITH_MULTIPROCESS) + set(bitcoin_gui_status ON) +else() + set(bitcoin_gui_status OFF) +endif() +message(" bitcoin-gui (GUI, multiprocess) ..... ${bitcoin_gui_status}") message(" bitcoin-cli ......................... ${BUILD_CLI}") message(" bitcoin-tx .......................... ${BUILD_TX}") message(" bitcoin-util ........................ ${BUILD_UTIL}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7de51472dad..ff8c30c5d18 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,6 +31,9 @@ add_dependencies(bitcoin_clientversion generate_build_info) add_subdirectory(crypto) add_subdirectory(univalue) add_subdirectory(util) +if(WITH_MULTIPROCESS) + add_subdirectory(ipc) +endif() #============================= # secp256k1 subtree @@ -297,6 +300,18 @@ if(BUILD_DAEMON) $ ) endif() +if(WITH_MULTIPROCESS) + add_executable(bitcoin-node + bitcoind.cpp + init/bitcoin-node.cpp + ) + target_link_libraries(bitcoin-node + core_interface + bitcoin_node + bitcoin_ipc + $ + ) +endif() add_library(bitcoin_cli STATIC EXCLUDE_FROM_ALL diff --git a/src/ipc/CMakeLists.txt b/src/ipc/CMakeLists.txt new file mode 100644 index 00000000000..94b1ceb54e4 --- /dev/null +++ b/src/ipc/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright (c) 2023-present The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or https://opensource.org/license/mit/. + +add_library(bitcoin_ipc STATIC EXCLUDE_FROM_ALL + capnp/protocol.cpp + interfaces.cpp + process.cpp +) + +target_capnp_sources(bitcoin_ipc ${PROJECT_SOURCE_DIR} + capnp/echo.capnp capnp/init.capnp +) + +target_link_libraries(bitcoin_ipc + PRIVATE + core_interface +) diff --git a/src/qt/CMakeLists.txt b/src/qt/CMakeLists.txt index 0a844c6a322..71f769b651e 100644 --- a/src/qt/CMakeLists.txt +++ b/src/qt/CMakeLists.txt @@ -243,6 +243,23 @@ if(WIN32) set_target_properties(bitcoin-qt PROPERTIES WIN32_EXECUTABLE TRUE) endif() +if(WITH_MULTIPROCESS) + add_executable(bitcoin-gui + main.cpp + ../init/bitcoin-gui.cpp + ) + target_link_libraries(bitcoin-gui + core_interface + bitcoinqt + bitcoin_node + bitcoin_ipc + ) + import_plugins(bitcoin-gui) + if(WIN32) + set_target_properties(bitcoin-gui PROPERTIES WIN32_EXECUTABLE TRUE) + endif() +endif() + if(BUILD_GUI_TESTS) add_subdirectory(test) endif() diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt index ee13bb5523e..a3624065b2f 100644 --- a/src/test/CMakeLists.txt +++ b/src/test/CMakeLists.txt @@ -158,6 +158,28 @@ if(ENABLE_WALLET) add_subdirectory(${PROJECT_SOURCE_DIR}/src/wallet/test wallet) endif() +if(WITH_MULTIPROCESS) + add_library(bitcoin_ipc_test STATIC EXCLUDE_FROM_ALL + ipc_test.cpp + ) + + target_capnp_sources(bitcoin_ipc_test ${PROJECT_SOURCE_DIR} + ipc_test.capnp + ) + + target_link_libraries(bitcoin_ipc_test + PRIVATE + core_interface + univalue + ) + + target_sources(test_bitcoin + PRIVATE + ipc_tests.cpp + ) + target_link_libraries(test_bitcoin bitcoin_ipc_test) +endif() + function(add_boost_test source_file) if(NOT EXISTS ${source_file}) return()