Skip to content

Commit

Permalink
cmake: Add external signer support
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Jan 29, 2024
1 parent dacc6f7 commit 80f54a7
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ tristate_option(WITH_USDT
"if sys/sdt.h is found."
AUTO
)
tristate_option(WITH_EXTERNAL_SIGNER
"Enable external signer support."
"if Boost.Process is found."
AUTO
)

option(BUILD_TESTS "Build test_bitcoin executable." ON)
option(BUILD_BENCH "Build bench_bitcoin executable." ON)
Expand Down Expand Up @@ -399,6 +404,7 @@ message(" SQLite, descriptor wallets .......... ${WITH_SQLITE}")
message(" Berkeley DB, legacy wallets ......... ${WITH_BDB}")
message("Optional packages:")
message(" GUI ................................. ${WITH_GUI}")
message(" external signer ..................... ${WITH_EXTERNAL_SIGNER}")
message(" NAT-PMP ............................. ${WITH_NATPMP}")
message(" UPnP ................................ ${WITH_MINIUPNPC}")
message(" ZeroMQ .............................. ${WITH_ZMQ}")
Expand Down
3 changes: 3 additions & 0 deletions cmake/bitcoin-config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,7 @@
/* Define if Berkeley DB (BDB) support should be compiled in. */
#cmakedefine USE_BDB

/* Define if external signer support is enabled. */
#cmakedefine ENABLE_EXTERNAL_SIGNER

#endif //BITCOIN_CONFIG_H
49 changes: 48 additions & 1 deletion cmake/module/AddBoostIfNeeded.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function(add_boost_if_needed)

set(Boost_NO_BOOST_CMAKE ON)
find_package(Boost 1.73.0 REQUIRED)
mark_as_advanced(Boost_INCLUDE_DIR)
set_target_properties(Boost::headers PROPERTIES IMPORTED_GLOBAL TRUE)
target_compile_definitions(Boost::headers INTERFACE
# We don't use multi_index serialization.
Expand Down Expand Up @@ -48,5 +49,51 @@ function(add_boost_if_needed)
endif()
endif()

mark_as_advanced(Boost_INCLUDE_DIR)
if(WITH_EXTERNAL_SIGNER)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIR})
set(CMAKE_REQUIRED_FLAGS "${working_compiler_werror_flag}")
# Boost 1.78 requires the following workaround.
# See: https://github.com/boostorg/process/issues/235
string(APPEND CMAKE_REQUIRED_FLAGS " -Wno-error=narrowing")
check_cxx_source_compiles("
#define BOOST_PROCESS_USE_STD_FS
#include <boost/process.hpp>
#include <string>
int main()
{
namespace bp = boost::process;
bp::opstream stdin_stream;
bp::ipstream stdout_stream;
bp::child c(\"dummy\", bp::std_out > stdout_stream, bp::std_err > stdout_stream, bp::std_in < stdin_stream);
stdin_stream << std::string{\"test\"} << std::endl;
if (c.running()) c.terminate();
c.wait();
c.exit_code();
}
" HAVE_BOOST_PROCESS
)
if(HAVE_BOOST_PROCESS)
if(WIN32)
# Boost Process for Windows uses Boost ASIO. Boost ASIO performs
# pre-main init of Windows networking libraries, which we do not
# want.
set(WITH_EXTERNAL_SIGNER OFF PARENT_SCOPE)
set(ENABLE_EXTERNAL_SIGNER OFF PARENT_SCOPE)
else()
set(WITH_EXTERNAL_SIGNER ON PARENT_SCOPE)
set(ENABLE_EXTERNAL_SIGNER ON PARENT_SCOPE)
target_compile_definitions(Boost::headers INTERFACE
BOOST_PROCESS_USE_STD_FS
)
endif()
elseif(WITH_EXTERNAL_SIGNER STREQUAL "AUTO")
set(WITH_EXTERNAL_SIGNER OFF PARENT_SCOPE)
set(ENABLE_EXTERNAL_SIGNER OFF PARENT_SCOPE)
else()
message(FATAL_ERROR "External signing is not supported for this Boost version.")
endif()
endif()

endfunction()

0 comments on commit 80f54a7

Please sign in to comment.