From 4ed97391f0e19bfcfff806fdf6ad4cdb2ddb0b69 Mon Sep 17 00:00:00 2001 From: Phillip Mienk Date: Wed, 18 Mar 2026 13:40:31 -0700 Subject: [PATCH] Integrate cmake refactor, presets installation correction. --- .github/workflows/ci.yml | 30 +- builds/cmake/CMakeLists.txt | 572 +++++++----------- builds/cmake/libbitcoin-node-config.cmake.in | 17 + .../cmake/modules/FindBash-Completion.cmake | 60 -- .../cmake/modules/FindBitcoin-Consensus.cmake | 60 -- .../cmake/modules/FindBitcoin-Database.cmake | 60 -- .../cmake/modules/FindBitcoin-Network.cmake | 60 -- install-cmake.sh | 216 ++----- install-cmakepresets.sh | 249 +++----- install.sh | 141 +---- 10 files changed, 385 insertions(+), 1080 deletions(-) create mode 100644 builds/cmake/libbitcoin-node-config.cmake.in delete mode 100644 builds/cmake/modules/FindBash-Completion.cmake delete mode 100644 builds/cmake/modules/FindBitcoin-Consensus.cmake delete mode 100644 builds/cmake/modules/FindBitcoin-Database.cmake delete mode 100644 builds/cmake/modules/FindBitcoin-Network.cmake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c541e00e..97ea86ac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -25,7 +25,6 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "" llvm: "" secp256k1: "--build-secp256k1" cc: "clang-18" @@ -42,7 +41,6 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "--build-icu --with-icu" llvm: "" secp256k1: "--build-secp256k1" cc: "clang-18" @@ -59,7 +57,6 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "" llvm: "" secp256k1: "--build-secp256k1" cc: "gcc-12" @@ -76,7 +73,6 @@ jobs: coverage: "cov" detectcpuflags: "detect" boost: "--build-boost" - icu: "--build-icu --with-icu" llvm: "" secp256k1: "--build-secp256k1" cc: "gcc" @@ -93,14 +89,13 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "--with-icu" llvm: "" secp256k1: "--build-secp256k1" cc: "clang" flags: "-Os -fPIE" options: "--enable-isystem" packager: "brew" - packages: "icu4c" + packages: "" - os: macos-latest cxx: "clang++" @@ -110,7 +105,6 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "--build-icu --with-icu" llvm: "" secp256k1: "--build-secp256k1" cc: "clang" @@ -131,7 +125,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Prepare toolchain [generic] run: | @@ -214,7 +208,6 @@ jobs: ${{ env.ASSERT_NDEBUG }} ${{ env.CPU_SUPPORTED_FLAGS }} ${{ matrix.boost }} - ${{ matrix.icu }} ${{ matrix.secp256k1 }} - name: Coveralls Calculation @@ -296,7 +289,6 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "" llvm: "" secp256k1: "--build-secp256k1" cc: "clang-18" @@ -313,7 +305,6 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "--build-icu --with-icu" llvm: "" secp256k1: "--build-secp256k1" cc: "clang-18" @@ -330,7 +321,6 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "" llvm: "" secp256k1: "--build-secp256k1" cc: "gcc-12" @@ -347,7 +337,6 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "--build-icu --with-icu" llvm: "" secp256k1: "--build-secp256k1" cc: "gcc-12" @@ -364,14 +353,13 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "--with-icu" llvm: "" secp256k1: "--build-secp256k1" cc: "clang" flags: "-Os -fPIE" options: "" packager: "brew" - packages: "icu4c" + packages: "" - os: macos-latest cxx: "clang++" @@ -381,7 +369,6 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "--build-icu --with-icu" llvm: "" secp256k1: "--build-secp256k1" cc: "clang" @@ -402,7 +389,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Prepare toolchain [generic] run: | @@ -488,7 +475,6 @@ jobs: ${{ env.ASSERT_NDEBUG }} ${{ env.CPU_SUPPORTED_FLAGS }} ${{ matrix.boost }} - ${{ matrix.icu }} ${{ matrix.secp256k1 }} - name: Coveralls Calculation @@ -581,7 +567,6 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "" llvm: "" secp256k1: "--build-secp256k1" cc: "clang-18" @@ -599,7 +584,6 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "--build-icu --with-icu" llvm: "" secp256k1: "--build-secp256k1" cc: "clang-18" @@ -617,7 +601,6 @@ jobs: coverage: "nocov" detectcpuflags: "ignore" boost: "--build-boost" - icu: "" llvm: "" secp256k1: "--build-secp256k1" cc: "gcc-12" @@ -638,7 +621,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Prepare toolchain [generic] run: | @@ -725,7 +708,6 @@ jobs: ${{ env.ASSERT_NDEBUG }} ${{ env.CPU_SUPPORTED_FLAGS }} ${{ matrix.boost }} - ${{ matrix.icu }} ${{ matrix.secp256k1 }} - name: Coveralls Calculation @@ -829,7 +811,7 @@ jobs: msbuild-architecture: x64 - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Initialize SDK shell: powershell diff --git a/builds/cmake/CMakeLists.txt b/builds/cmake/CMakeLists.txt index 1083579d..c161aa4d 100644 --- a/builds/cmake/CMakeLists.txt +++ b/builds/cmake/CMakeLists.txt @@ -4,399 +4,289 @@ # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY # ############################################################################### +cmake_minimum_required(VERSION 3.30 FATAL_ERROR) -# libbitcoin-node project configuration. -#------------------------------------------------------------------------------ -cmake_minimum_required(VERSION 3.18 FATAL_ERROR) +project( libbitcoin-node + VERSION 4.0.0 + DESCRIPTION "Bitcoin Full Node" + LANGUAGES C CXX ) -project(libbitcoin-node LANGUAGES C CXX) -enable_testing() +set( repository_root_dir "${CMAKE_CURRENT_SOURCE_DIR}/../../" ) -list( APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/modules" ) -include(CheckIncludeFiles) -include(CheckSymbolExists) -include(CheckCXXCompilerFlag) -include(CheckCXXSourceCompiles) -include(CheckLinkerFlag) +if ( MSVC ) + set( CMAKE_STATIC_LIBRARY_PREFIX "lib" ) + set( CMAKE_SHARED_LIBRARY_PREFIX "lib" ) +endif() -set_property(GLOBAL PROPERTY USE_FOLDERS ON) +#------------------------------------------------------------------------------ +# Project options. +#------------------------------------------------------------------------------ +option( with-test "Build test." ON ) -if (MSVC) - set( CANONICAL_LIB_NAME libbitcoin-node ) -else () - set( CANONICAL_LIB_NAME bitcoin-node ) - find_package( PkgConfig REQUIRED ) +#------------------------------------------------------------------------------ +# Dependencies. +#------------------------------------------------------------------------------ - set( prefix "${CMAKE_PREFIX_PATH}" ) - set( exec_prefix "\${prefix}" ) - set( libdir "\${exec_prefix}/lib" ) - set( includedir "\${exec_prefix}/include" ) +if ( BUILD_SHARED_LIBS ) + set( libbitcoin-database_USE_STATIC_LIBS "OFF" ) + set( libbitcoin-network_USE_STATIC_LIBS "OFF" ) + set( Boost_USE_STATIC_LIBS "OFF" ) +else() + set( libbitcoin-database_USE_STATIC_LIBS "ON" ) + set( libbitcoin-network_USE_STATIC_LIBS "ON" ) + set( Boost_USE_STATIC_LIBS "ON" ) +endif() - set( CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" ) +find_package( libbitcoin-database 4.0.0 REQUIRED ) - set( PACKAGE_VERSION "4.0.0" ) - set( VERSION "${PACKAGE_VERSION}" ) -endif () +find_package( libbitcoin-network 4.0.0 REQUIRED ) -set( CMAKE_CXX_STANDARD 20 ) -set( CMAKE_CXX_STANDARD_REQUIRED ON ) +find_package( Boost 1.86.0 REQUIRED + COMPONENTS + unit_test_framework +) -# Add compiler options #------------------------------------------------------------------------------ -# Warn on all stuff. +# Compiler options. +#------------------------------------------------------------------------------ + +include(CheckCCompilerFlag) +include(CheckCXXCompilerFlag) +include(CheckCXXSourceCompiles) + check_cxx_compiler_flag( "-Wall" HAS_FLAG_WALL ) -if ( HAS_FLAG_WALL ) - add_compile_options( $<$:-Wall> ) -else() - message( FATAL_ERROR "Compiler does not support -Wall" ) +if ( !HAS_FLAG_WALL ) + message( FATAL_ERROR "Compiler does not support '-Wall'." ) endif() -# Warn on extra stuff. check_cxx_compiler_flag( "-Wextra" HAS_FLAG_WEXTRA ) -if ( HAS_FLAG_WEXTRA ) - add_compile_options( $<$:-Wextra> ) -else() - message( FATAL_ERROR "Compiler does not support -Wextra" ) +if ( !HAS_FLAG_WEXTRA ) + message( FATAL_ERROR "Compiler does not support '-Wextra'." ) endif() -# Disallow warning on style order of declarations. check_cxx_compiler_flag( "-Wno-reorder" HAS_FLAG_WNO-REORDER ) -if ( HAS_FLAG_WNO-REORDER ) - add_compile_options( $<$:-Wno-reorder> ) -else() - message( FATAL_ERROR "Compiler does not support -Wno-reorder" ) +if ( !HAS_FLAG_WNO-REORDER ) + message( FATAL_ERROR "Compiler does not support '-Wno-reorder'." ) endif() -# Suppress warning for incomplete field initialization. check_cxx_compiler_flag( "-Wno-missing-field-initializers" HAS_FLAG_WNO-MISSING-FIELD-INITIALIZERS ) -if ( HAS_FLAG_WNO-MISSING-FIELD-INITIALIZERS ) - add_compile_options( $<$:-Wno-missing-field-initializers> ) -else() - message( FATAL_ERROR "Compiler does not support -Wno-missing-field-initializers" ) +if ( !HAS_FLAG_WNO-MISSING-FIELD-INITIALIZERS ) + message( FATAL_ERROR "Compiler does not support '-Wno-missing-field-initializers'." ) endif() -# Conform to style. check_cxx_compiler_flag( "-Wno-missing-braces" HAS_FLAG_WNO-MISSING-BRACES ) -if ( HAS_FLAG_WNO-MISSING-BRACES ) - add_compile_options( $<$:-Wno-missing-braces> ) -else() - message( FATAL_ERROR "Compiler does not support -Wno-missing-braces" ) +if ( !HAS_FLAG_WNO-MISSING-BRACES ) + message( FATAL_ERROR "Compiler does not support '-Wno-missing-braces'." ) endif() -# Ignore comments within comments or commenting of backslash extended lines. check_cxx_compiler_flag( "-Wno-comment" HAS_FLAG_WNO-COMMENT ) -if ( HAS_FLAG_WNO-COMMENT ) - add_compile_options( $<$:-Wno-comment> ) -else() - message( FATAL_ERROR "Compiler does not support -Wno-comment" ) +if ( !HAS_FLAG_WNO-COMMENT ) + message( FATAL_ERROR "Compiler does not support '-Wno-comment'." ) endif() -# Suppress warning for copy of implicitly generated copy constructor. check_cxx_compiler_flag( "-Wno-deprecated-copy" HAS_FLAG_WNO-DEPRECATED-COPY ) -if ( HAS_FLAG_WNO-DEPRECATED-COPY ) - add_compile_options( $<$:-Wno-deprecated-copy> ) -else() - message( FATAL_ERROR "Compiler does not support -Wno-deprecated-copy" ) +if ( !HAS_FLAG_WNO-DEPRECATED-COPY ) + message( FATAL_ERROR "Compiler does not support '-Wno-deprecated-copy'." ) endif() -# Conflict in stdlib under clang. -if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - check_cxx_compiler_flag( "-Wno-mismatched-tags" HAS_FLAG_WNO-MISMATCHED-TAGS ) - if ( HAS_FLAG_WNO-MISMATCHED-TAGS ) - add_compile_options( $<$:-Wno-mismatched-tags> ) - else() - message( FATAL_ERROR "Compiler does not support -Wno-mismatched-tags" ) - endif() +if ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" ) + check_cxx_compiler_flag( "-Wno-mismatched-tags" HAS_FLAG_WNO-MISMATCHED-TAGS ) + if ( !HAS_FLAG_WNO-MISMATCHED-TAGS ) + message( FATAL_ERROR "Compiler does not support '-Wno-mismatched-tags'." ) + endif() endif() -# Implement -Dbash-completiondir and output ${bash-completiondir} and declare bash-completiondir. -#------------------------------------------------------------------------------ -set( bash-completiondir "no" CACHE BOOL "Install bash completion support, optionally specifying the directory. This option may require elevated permissions." ) - -# Implement -Dpkgconfigdir and output ${pkgconfigdir}. -#------------------------------------------------------------------------------ -set( pkgconfigdir "${libdir}/pkgconfig" CACHE PATH "Path to pkgconfig directory." ) - -# Implement -Dwith-tests and declare with-tests. -#------------------------------------------------------------------------------ -set( with-tests "yes" CACHE BOOL "Compile with unit tests." ) - -# Implement -Dwith-console and declare with-console. -#------------------------------------------------------------------------------ -set( with-console "yes" CACHE BOOL "Compile console application." ) - -# Implement -Denable-ndebug and define NDEBUG. -#------------------------------------------------------------------------------ -set( enable-ndebug "yes" CACHE BOOL "Compile without debug assertions." ) - -if (enable-ndebug) - add_definitions( -DNDEBUG ) +check_cxx_compiler_flag( "-fstack-protector-all" HAS_FLAG_FSTACK-PROTECTOR-ALL ) +if ( !HAS_FLAG_FSTACK-PROTECTOR-ALL ) + message( FATAL_ERROR "Compiler does not support '-fstack-protector-all'." ) endif() -# Inherit -Denable-shared and define BOOST_ALL_DYN_LINK. -#------------------------------------------------------------------------------ -if (BUILD_SHARED_LIBS) - add_definitions( -DBOOST_ALL_DYN_LINK ) +check_cxx_compiler_flag( "-Wno-ignored-attributes" HAS_FLAG_WNO-IGNORED-ATTRIBUTES ) +if ( !HAS_FLAG_WNO-IGNORED-ATTRIBUTES ) + message( FATAL_ERROR "Compiler does not support '-Wno-ignored-attributes'." ) endif() -if (BUILD_SHARED_LIBS) - set( Boost_USE_STATIC_LIBS "off" ) -else() - set( Boost_USE_STATIC_LIBS "on" ) +check_cxx_compiler_flag( "-Wno-long-long" HAS_FLAG_WNO-LONG-LONG ) +if ( !HAS_FLAG_WNO-LONG-LONG ) + message( FATAL_ERROR "Compiler does not support '-Wno-long-long'." ) endif() -# Find boost -#------------------------------------------------------------------------------ -find_package( Boost 1.86.0 REQUIRED COMPONENTS - unit_test_framework ) - -set( boost_unit_test_framework_LIBS "-lboost_unit_test_framework" ) - -set( Boost_LIBRARY_DIR $,"${Boost_LIBRARY_DIR_RELEASE}","${Boost_LIBRARY_DIR_DEBUG}">) - -set( boost_CPPFLAGS "-I${Boost_INCLUDE_DIR}" ) -set( boost_LDFLAGS "-L${Boost_LIBRARY_DIR}" ) - -# Find bash-completion -#------------------------------------------------------------------------------ -if (bash-completiondir) - find_package( Bash-Completion 2.0.0 REQUIRED ) +if ( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" ) + check_cxx_compiler_flag( "-fno-var-tracking-assignments" HAS_FLAG_FNO-VAR-TRACKING-ASSIGNMENTS ) + if ( !HAS_FLAG_FNO-VAR-TRACKING-ASSIGNMENTS ) + message( FATAL_ERROR "Compiler does not support '-fno-var-tracking-assignments'." ) + endif() endif() -# Find bitcoin-database #------------------------------------------------------------------------------ -find_package( Bitcoin-Database 4.0.0 REQUIRED ) - -# Find bitcoin-network +# Linker options. #------------------------------------------------------------------------------ -find_package( Bitcoin-Network 4.0.0 REQUIRED ) -# Define project common includes for build. -#------------------------------------------------------------------------------ -if (BUILD_SHARED_LIBS) - set( bitcoin_database_FOR_BUILD_INCLUDE_DIRS ${bitcoin_database_INCLUDE_DIRS} CACHE STRING "Placeholder" ) - set( bitcoin_network_FOR_BUILD_INCLUDE_DIRS ${bitcoin_network_INCLUDE_DIRS} CACHE STRING "Placeholder" ) -else() - set( bitcoin_database_FOR_BUILD_INCLUDE_DIRS ${bitcoin_database_STATIC_INCLUDE_DIRS} CACHE STRING "Placeholder" ) - set( bitcoin_network_FOR_BUILD_INCLUDE_DIRS ${bitcoin_network_STATIC_INCLUDE_DIRS} CACHE STRING "Placeholder" ) -endif() - -# Define project common includes directories -#------------------------------------------------------------------------------ -include_directories( SYSTEM - ${bitcoin_database_FOR_BUILD_INCLUDE_DIRS} - ${bitcoin_network_FOR_BUILD_INCLUDE_DIRS} ) - -# Define project common library directories for build. -#------------------------------------------------------------------------------ -if (BUILD_SHARED_LIBS) - set( bitcoin_database_FOR_BUILD_LIBRARY_DIRS ${bitcoin_database_LIBRARY_DIRS} CACHE STRING "Placeholder" ) - set( bitcoin_network_FOR_BUILD_LIBRARY_DIRS ${bitcoin_network_LIBRARY_DIRS} CACHE STRING "Placeholder" ) -else() - set( bitcoin_database_FOR_BUILD_LIBRARY_DIRS ${bitcoin_database_STATIC_LIBRARY_DIRS} CACHE STRING "Placeholder" ) - set( bitcoin_network_FOR_BUILD_LIBRARY_DIRS ${bitcoin_network_STATIC_LIBRARY_DIRS} CACHE STRING "Placeholder" ) -endif() - -# Define project common library directories -#------------------------------------------------------------------------------ -link_directories( - ${bitcoin_database_FOR_BUILD_LIBRARY_DIRS} - ${bitcoin_network_FOR_BUILD_LIBRARY_DIRS} ) - -# Define project common linker flags. -#------------------------------------------------------------------------------ -check_linker_flag(CXX "-no_fixup_chains" "no_fixup_chains_FOUND") - -if (no_fixup_chains_FOUND) - add_link_options("-no_fixup_chains") -endif() - -check_linker_flag(CXX "-fstack-protector" "fstack_protector_FOUND") - -if (fstack_protector_FOUND) - add_link_options("-fstack-protector") -endif() - -check_linker_flag(CXX "-fstack-protector-all" "fstack_protector_all_FOUND") - -if (fstack_protector_all_FOUND) - add_link_options("-fstack-protector-all") -endif() - - -# Define common library usage for build. -#------------------------------------------------------------------------------ -if (BUILD_SHARED_LIBS) - set( bitcoin_database_FOR_BUILD_LIBRARIES ${bitcoin_database_LIBRARIES} CACHE STRING "Placeholder" ) - set( bitcoin_network_FOR_BUILD_LIBRARIES ${bitcoin_network_LIBRARIES} CACHE STRING "Placeholder" ) -else() - set( bitcoin_database_FOR_BUILD_LIBRARIES ${bitcoin_database_STATIC_LIBRARIES} CACHE STRING "Placeholder" ) - set( bitcoin_network_FOR_BUILD_LIBRARIES ${bitcoin_network_STATIC_LIBRARIES} CACHE STRING "Placeholder" ) -endif() - -# Define project common libraries. -#------------------------------------------------------------------------------ -link_libraries( - ${bitcoin_database_FOR_BUILD_LIBRARIES} - ${bitcoin_network_FOR_BUILD_LIBRARIES} ) - -add_definitions( - -DSYSCONFDIR=\"${sysconfdir}\" ) +include(CheckLinkerFlag) -# Define ${CANONICAL_LIB_NAME} project. #------------------------------------------------------------------------------ -add_library( ${CANONICAL_LIB_NAME} - "../../src/block_arena.cpp" - "../../src/block_memory.cpp" - "../../src/configuration.cpp" - "../../src/error.cpp" - "../../src/full_node.cpp" - "../../src/settings.cpp" - "../../src/channels/channel_peer.cpp" - "../../src/chasers/chaser.cpp" - "../../src/chasers/chaser_block.cpp" - "../../src/chasers/chaser_check.cpp" - "../../src/chasers/chaser_confirm.cpp" - "../../src/chasers/chaser_header.cpp" - "../../src/chasers/chaser_snapshot.cpp" - "../../src/chasers/chaser_storage.cpp" - "../../src/chasers/chaser_template.cpp" - "../../src/chasers/chaser_transaction.cpp" - "../../src/chasers/chaser_validate.cpp" - "../../src/protocols/protocol.cpp" - "../../src/protocols/protocol_block_in_106.cpp" - "../../src/protocols/protocol_block_in_31800.cpp" - "../../src/protocols/protocol_block_out_106.cpp" - "../../src/protocols/protocol_block_out_70012.cpp" - "../../src/protocols/protocol_filter_out_70015.cpp" - "../../src/protocols/protocol_header_in_31800.cpp" - "../../src/protocols/protocol_header_in_70012.cpp" - "../../src/protocols/protocol_header_out_31800.cpp" - "../../src/protocols/protocol_header_out_70012.cpp" - "../../src/protocols/protocol_observer.cpp" - "../../src/protocols/protocol_peer.cpp" - "../../src/protocols/protocol_performer.cpp" - "../../src/protocols/protocol_transaction_in_106.cpp" - "../../src/protocols/protocol_transaction_out_106.cpp" - "../../src/sessions/session.cpp" - "../../src/sessions/session_inbound.cpp" - "../../src/sessions/session_manual.cpp" - "../../src/sessions/session_outbound.cpp" ) - -# ${CANONICAL_LIB_NAME} project specific include directory normalization for build. +# libbitcoin-node library #------------------------------------------------------------------------------ -if (BUILD_SHARED_LIBS) - set( bitcoin_database_FOR_BUILD_INCLUDE_DIRS ${bitcoin_database_INCLUDE_DIRS} CACHE STRING "Placeholder" ) - set( bitcoin_network_FOR_BUILD_INCLUDE_DIRS ${bitcoin_network_INCLUDE_DIRS} CACHE STRING "Placeholder" ) -else() - set( bitcoin_database_FOR_BUILD_INCLUDE_DIRS ${bitcoin_database_STATIC_INCLUDE_DIRS} CACHE STRING "Placeholder" ) - set( bitcoin_network_FOR_BUILD_INCLUDE_DIRS ${bitcoin_network_STATIC_INCLUDE_DIRS} CACHE STRING "Placeholder" ) -endif() +add_library( libbitcoin-node ) +add_library( bitcoin::node ALIAS libbitcoin-node ) + +target_compile_features( libbitcoin-node + PUBLIC + cxx_std_20 +) + +target_compile_options( libbitcoin-node + PRIVATE + -Wall + -Wextra + $<$:-Wno-reorder> + $<$:-Wno-missing-field-initializers> + $<$:-Wno-missing-braces> + $<$:-Wno-comment> + $<$:-Wno-deprecated-copy> + $<$:-Wno-mismatched-tags> + -fstack-protector-all +) + +file( GLOB_RECURSE libbitcoin_node_HEADERS CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/../../include/*.h" + "${CMAKE_CURRENT_SOURCE_DIR}/../../include/*.hpp" + "${CMAKE_CURRENT_SOURCE_DIR}/../../include/*.ipp" +) + +file( GLOB_RECURSE libbitcoin_node_SOURCES CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/../../src/*.c" + "${CMAKE_CURRENT_SOURCE_DIR}/../../src/*.cpp" +) + +target_sources( libbitcoin-node + PUBLIC + FILE_SET HEADERS + BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/../../include" + FILES + ${libbitcoin_node_HEADERS} + PRIVATE + ${libbitcoin_node_SOURCES} +) + +target_include_directories( libbitcoin-node + PUBLIC + $ + $ +) + +target_link_libraries( libbitcoin-node + PUBLIC + bitcoin::database + bitcoin::network +) + +set_target_properties( libbitcoin-node + PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + EXPORT_NAME node + OUTPUT_NAME bitcoin-node +) -# ${CANONICAL_LIB_NAME} project specific include directories. #------------------------------------------------------------------------------ -target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE - "../../include" - ${bitcoin_database_FOR_BUILD_INCLUDE_DIRS} - ${bitcoin_network_FOR_BUILD_INCLUDE_DIRS} ) - -target_include_directories( ${CANONICAL_LIB_NAME} PUBLIC -"../../include" ) - -# ${CANONICAL_LIB_NAME} project specific libraries noramalization for build. +# libbitcoin-node-tests tests #------------------------------------------------------------------------------ -if (BUILD_SHARED_LIBS) - set( bitcoin_database_FOR_BUILD_LIBRARIES ${bitcoin_database_LIBRARIES} CACHE STRING "Placeholder" ) - set( bitcoin_network_FOR_BUILD_LIBRARIES ${bitcoin_network_LIBRARIES} CACHE STRING "Placeholder" ) -else() - set( bitcoin_database_FOR_BUILD_LIBRARIES ${bitcoin_database_STATIC_LIBRARIES} CACHE STRING "Placeholder" ) - set( bitcoin_network_FOR_BUILD_LIBRARIES ${bitcoin_network_STATIC_LIBRARIES} CACHE STRING "Placeholder" ) +if ( with-test ) + add_executable( libbitcoin-node-tests ) + + enable_testing() + + add_test( NAME libbitcoin-node-tests + COMMAND libbitcoin-node-tests + --run_test=* + --log_level=warning + --show_progress=no + --detect_memory_leak=0 + --report_level=no + --build_info=yes + ) + + target_compile_features( libbitcoin-node-tests + PUBLIC + cxx_std_20 + ) + + target_compile_options( libbitcoin-node-tests + PRIVATE + -Wall + -Wextra + $<$:-Wno-reorder> + $<$:-Wno-missing-field-initializers> + $<$:-Wno-missing-braces> + $<$:-Wno-comment> + $<$:-Wno-deprecated-copy> + $<$:-Wno-ignored-attributes> + $<$:-Wno-mismatched-tags> + $<$:-Wno-long-long> + $<$:-fno-var-tracking-assignments> + -fstack-protector-all + ) + + file( GLOB_RECURSE libbitcoin_node_tests_SOURCES CONFIGURE_DEPENDS + "${CMAKE_CURRENT_SOURCE_DIR}/../../test/*.c" + "${CMAKE_CURRENT_SOURCE_DIR}/../../test/*.cpp" + ) + + target_sources( libbitcoin-node-tests + PRIVATE + ${libbitcoin_node_tests_SOURCES} + ) + + target_link_libraries( libbitcoin-node-tests + PRIVATE + Boost::unit_test_framework + bitcoin::node + ) + + set_target_properties( libbitcoin-node-tests + PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${PROJECT_VERSION_MAJOR} + ) endif() - -# ${CANONICAL_LIB_NAME} project specific libraries/linker flags. -#------------------------------------------------------------------------------ -target_link_libraries( ${CANONICAL_LIB_NAME} - ${bitcoin_database_FOR_BUILD_LIBRARIES} - ${bitcoin_network_FOR_BUILD_LIBRARIES} ) - -# Define libbitcoin-node-test project. -#------------------------------------------------------------------------------ -if (with-tests) - add_executable( libbitcoin-node-test - "../../test/block_arena.cpp" - "../../test/block_memory.cpp" - "../../test/channel_peer.cpp" - "../../test/configuration.cpp" - "../../test/error.cpp" - "../../test/full_node.cpp" - "../../test/main.cpp" - "../../test/settings.cpp" - "../../test/test.cpp" - "../../test/test.hpp" - "../../test/chasers/chaser.cpp" - "../../test/chasers/chaser_block.cpp" - "../../test/chasers/chaser_check.cpp" - "../../test/chasers/chaser_confirm.cpp" - "../../test/chasers/chaser_header.cpp" - "../../test/chasers/chaser_template.cpp" - "../../test/chasers/chaser_transaction.cpp" - "../../test/chasers/chaser_validate.cpp" - "../../test/protocols/protocol.cpp" - "../../test/sessions/session.cpp" ) - - add_test( NAME libbitcoin-node-test COMMAND libbitcoin-node-test - --run_test=* - --log_level=warning - --show_progress=no - --detect_memory_leak=0 - --report_level=no - --build_info=yes ) - -# libbitcoin-node-test project specific include directories. #------------------------------------------------------------------------------ - target_include_directories( libbitcoin-node-test PRIVATE - "../../include" ) - -# libbitcoin-node-test project specific libraries/linker flags. +# Installation routine. #------------------------------------------------------------------------------ - target_link_libraries( libbitcoin-node-test - ${CANONICAL_LIB_NAME} - ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} ) - -endif() - -# Manage pkgconfig installation. -#------------------------------------------------------------------------------ -configure_file( - "../../libbitcoin-node.pc.in" - "libbitcoin-node.pc" @ONLY ) - -install( FILES - "${CMAKE_CURRENT_BINARY_DIR}/libbitcoin-node.pc" - DESTINATION "${pkgconfigdir}" ) - -# Manage installation of docs. -#------------------------------------------------------------------------------ -install( FILES - "../../AUTHORS" - "../../COPYING" - "../../ChangeLog" - "../../INSTALL" - "../../NEWS" - "../../README" - DESTINATION share/doc/libbitcoin-node ) - -# Manage ${CANONICAL_LIB_NAME} installation. -#------------------------------------------------------------------------------ -install( TARGETS ${CANONICAL_LIB_NAME} - RUNTIME DESTINATION bin - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - PUBLIC_HEADER DESTINATION include ) - -# Manage include installation. -#------------------------------------------------------------------------------ -install( DIRECTORY "../../include/bitcoin" - DESTINATION include ) - +include( GNUInstallDirs ) +include( CMakePackageConfigHelpers ) + +install( TARGETS libbitcoin-node + EXPORT libbitcoin-node-targets + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + FILE_SET HEADERS +) + +install( EXPORT libbitcoin-node-targets + NAMESPACE bitcoin:: + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libbitcoin-node + FILE libbitcoin-node-targets.cmake +) + +configure_package_config_file( + ${CMAKE_CURRENT_SOURCE_DIR}/libbitcoin-node-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/libbitcoin-node-config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libbitcoin-node +) + +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/libbitcoin-node-config-version.cmake" + VERSION ${PACKAGE_VERSION} + COMPATIBILITY SameMajorVersion +) + +install( + FILES + ${CMAKE_CURRENT_BINARY_DIR}/libbitcoin-node-config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/libbitcoin-node-config-version.cmake + DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libbitcoin-node +) diff --git a/builds/cmake/libbitcoin-node-config.cmake.in b/builds/cmake/libbitcoin-node-config.cmake.in new file mode 100644 index 00000000..cdf832a0 --- /dev/null +++ b/builds/cmake/libbitcoin-node-config.cmake.in @@ -0,0 +1,17 @@ +############################################################################### +# Copyright (c) 2014-2026 libbitcoin-node developers (see COPYING). +# +# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY +# +############################################################################### +@PACKAGE_INIT@ + +include( CMakeFindDependencyMacro ) + +include( "${CMAKE_CURRENT_LIST_DIR}/libbitcoin-node-targets.cmake" ) + +find_dependency( libbitcoin-database 4.0.0 REQUIRED ) + +find_dependency( libbitcoin-network 4.0.0 REQUIRED ) + +check_required_components(@PROJECT_NAME@) diff --git a/builds/cmake/modules/FindBash-Completion.cmake b/builds/cmake/modules/FindBash-Completion.cmake deleted file mode 100644 index f877b31a..00000000 --- a/builds/cmake/modules/FindBash-Completion.cmake +++ /dev/null @@ -1,60 +0,0 @@ -############################################################################### -# Copyright (c) 2014-2026 libbitcoin-server developers (see COPYING). -# -# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY -# -############################################################################### -# FindBash-Completion -# -# Use this module by invoking find_package with the form:: -# -# find_package( Bash-Completion -# [version] # Minimum version -# [REQUIRED] # Fail with error if bash-completion is not found -# ) -# -# Defines the following for use: -# -# bash_completion_FOUND - true if headers and requested libraries were found -# bash_completion_INCLUDE_DIRS - include directories for bash-completion libraries -# bash_completion_LIBRARY_DIRS - link directories for bash-completion libraries -# bash_completion_LIBRARIES - bash-completion libraries to be linked -# bash_completion_PKG - bash-completion pkg-config package specification. -# - -if (MSVC) - if ( Bash-Completion_FIND_REQUIRED ) - set( _bash_completion_MSG_STATUS "SEND_ERROR" ) - else () - set( _bash_completion_MSG_STATUS "STATUS" ) - endif() - - set( bash_completion_FOUND false ) - message( ${_bash_completion_MSG_STATUS} "MSVC environment detection for 'bash-completion' not currently supported." ) -else () - # required - if ( Bash-Completion_FIND_REQUIRED ) - set( _bash_completion_REQUIRED "REQUIRED" ) - endif() - - # quiet - if ( Bash-Completion_FIND_QUIETLY ) - set( _bash_completion_QUIET "QUIET" ) - endif() - - # modulespec - if ( Bash-Completion_FIND_VERSION_COUNT EQUAL 0 ) - set( _bash_completion_MODULE_SPEC "bash-completion" ) - else () - if ( Bash-Completion_FIND_VERSION_EXACT ) - set( _bash_completion_MODULE_SPEC_OP "=" ) - else () - set( _bash_completion_MODULE_SPEC_OP ">=" ) - endif() - - set( _bash_completion_MODULE_SPEC "bash-completion ${_bash_completion_MODULE_SPEC_OP} ${Bash-Completion_FIND_VERSION}" ) - endif() - - pkg_check_modules( bash_completion ${_bash_completion_REQUIRED} ${_bash_completion_QUIET} "${_bash_completion_MODULE_SPEC}" ) - set( bash_completion_PKG "${_bash_completion_MODULE_SPEC}" ) -endif() diff --git a/builds/cmake/modules/FindBitcoin-Consensus.cmake b/builds/cmake/modules/FindBitcoin-Consensus.cmake deleted file mode 100644 index 99b31361..00000000 --- a/builds/cmake/modules/FindBitcoin-Consensus.cmake +++ /dev/null @@ -1,60 +0,0 @@ -############################################################################### -# Copyright (c) 2014-2026 libbitcoin-blockchain developers (see COPYING). -# -# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY -# -############################################################################### -# FindBitcoin-Consensus -# -# Use this module by invoking find_package with the form:: -# -# find_package( Bitcoin-Consensus -# [version] # Minimum version -# [REQUIRED] # Fail with error if bitcoin-consensus is not found -# ) -# -# Defines the following for use: -# -# bitcoin_consensus_FOUND - true if headers and requested libraries were found -# bitcoin_consensus_INCLUDE_DIRS - include directories for bitcoin-consensus libraries -# bitcoin_consensus_LIBRARY_DIRS - link directories for bitcoin-consensus libraries -# bitcoin_consensus_LIBRARIES - bitcoin-consensus libraries to be linked -# bitcoin_consensus_PKG - bitcoin-consensus pkg-config package specification. -# - -if (MSVC) - if ( Bitcoin-Consensus_FIND_REQUIRED ) - set( _bitcoin_consensus_MSG_STATUS "SEND_ERROR" ) - else () - set( _bitcoin_consensus_MSG_STATUS "STATUS" ) - endif() - - set( bitcoin_consensus_FOUND false ) - message( ${_bitcoin_consensus_MSG_STATUS} "MSVC environment detection for 'bitcoin-consensus' not currently supported." ) -else () - # required - if ( Bitcoin-Consensus_FIND_REQUIRED ) - set( _bitcoin_consensus_REQUIRED "REQUIRED" ) - endif() - - # quiet - if ( Bitcoin-Consensus_FIND_QUIETLY ) - set( _bitcoin_consensus_QUIET "QUIET" ) - endif() - - # modulespec - if ( Bitcoin-Consensus_FIND_VERSION_COUNT EQUAL 0 ) - set( _bitcoin_consensus_MODULE_SPEC "libbitcoin-consensus" ) - else () - if ( Bitcoin-Consensus_FIND_VERSION_EXACT ) - set( _bitcoin_consensus_MODULE_SPEC_OP "=" ) - else () - set( _bitcoin_consensus_MODULE_SPEC_OP ">=" ) - endif() - - set( _bitcoin_consensus_MODULE_SPEC "libbitcoin-consensus ${_bitcoin_consensus_MODULE_SPEC_OP} ${Bitcoin-Consensus_FIND_VERSION}" ) - endif() - - pkg_check_modules( bitcoin_consensus ${_bitcoin_consensus_REQUIRED} ${_bitcoin_consensus_QUIET} "${_bitcoin_consensus_MODULE_SPEC}" ) - set( bitcoin_consensus_PKG "${_bitcoin_consensus_MODULE_SPEC}" ) -endif() diff --git a/builds/cmake/modules/FindBitcoin-Database.cmake b/builds/cmake/modules/FindBitcoin-Database.cmake deleted file mode 100644 index 596b88da..00000000 --- a/builds/cmake/modules/FindBitcoin-Database.cmake +++ /dev/null @@ -1,60 +0,0 @@ -############################################################################### -# Copyright (c) 2014-2026 libbitcoin-blockchain developers (see COPYING). -# -# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY -# -############################################################################### -# FindBitcoin-Database -# -# Use this module by invoking find_package with the form:: -# -# find_package( Bitcoin-Database -# [version] # Minimum version -# [REQUIRED] # Fail with error if bitcoin-database is not found -# ) -# -# Defines the following for use: -# -# bitcoin_database_FOUND - true if headers and requested libraries were found -# bitcoin_database_INCLUDE_DIRS - include directories for bitcoin-database libraries -# bitcoin_database_LIBRARY_DIRS - link directories for bitcoin-database libraries -# bitcoin_database_LIBRARIES - bitcoin-database libraries to be linked -# bitcoin_database_PKG - bitcoin-database pkg-config package specification. -# - -if (MSVC) - if ( Bitcoin-Database_FIND_REQUIRED ) - set( _bitcoin_database_MSG_STATUS "SEND_ERROR" ) - else () - set( _bitcoin_database_MSG_STATUS "STATUS" ) - endif() - - set( bitcoin_database_FOUND false ) - message( ${_bitcoin_database_MSG_STATUS} "MSVC environment detection for 'bitcoin-database' not currently supported." ) -else () - # required - if ( Bitcoin-Database_FIND_REQUIRED ) - set( _bitcoin_database_REQUIRED "REQUIRED" ) - endif() - - # quiet - if ( Bitcoin-Database_FIND_QUIETLY ) - set( _bitcoin_database_QUIET "QUIET" ) - endif() - - # modulespec - if ( Bitcoin-Database_FIND_VERSION_COUNT EQUAL 0 ) - set( _bitcoin_database_MODULE_SPEC "libbitcoin-database" ) - else () - if ( Bitcoin-Database_FIND_VERSION_EXACT ) - set( _bitcoin_database_MODULE_SPEC_OP "=" ) - else () - set( _bitcoin_database_MODULE_SPEC_OP ">=" ) - endif() - - set( _bitcoin_database_MODULE_SPEC "libbitcoin-database ${_bitcoin_database_MODULE_SPEC_OP} ${Bitcoin-Database_FIND_VERSION}" ) - endif() - - pkg_check_modules( bitcoin_database ${_bitcoin_database_REQUIRED} ${_bitcoin_database_QUIET} "${_bitcoin_database_MODULE_SPEC}" ) - set( bitcoin_database_PKG "${_bitcoin_database_MODULE_SPEC}" ) -endif() diff --git a/builds/cmake/modules/FindBitcoin-Network.cmake b/builds/cmake/modules/FindBitcoin-Network.cmake deleted file mode 100644 index 7851bf99..00000000 --- a/builds/cmake/modules/FindBitcoin-Network.cmake +++ /dev/null @@ -1,60 +0,0 @@ -############################################################################### -# Copyright (c) 2014-2026 libbitcoin-node developers (see COPYING). -# -# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY -# -############################################################################### -# FindBitcoin-Network -# -# Use this module by invoking find_package with the form:: -# -# find_package( Bitcoin-Network -# [version] # Minimum version -# [REQUIRED] # Fail with error if bitcoin-network is not found -# ) -# -# Defines the following for use: -# -# bitcoin_network_FOUND - true if headers and requested libraries were found -# bitcoin_network_INCLUDE_DIRS - include directories for bitcoin-network libraries -# bitcoin_network_LIBRARY_DIRS - link directories for bitcoin-network libraries -# bitcoin_network_LIBRARIES - bitcoin-network libraries to be linked -# bitcoin_network_PKG - bitcoin-network pkg-config package specification. -# - -if (MSVC) - if ( Bitcoin-Network_FIND_REQUIRED ) - set( _bitcoin_network_MSG_STATUS "SEND_ERROR" ) - else () - set( _bitcoin_network_MSG_STATUS "STATUS" ) - endif() - - set( bitcoin_network_FOUND false ) - message( ${_bitcoin_network_MSG_STATUS} "MSVC environment detection for 'bitcoin-network' not currently supported." ) -else () - # required - if ( Bitcoin-Network_FIND_REQUIRED ) - set( _bitcoin_network_REQUIRED "REQUIRED" ) - endif() - - # quiet - if ( Bitcoin-Network_FIND_QUIETLY ) - set( _bitcoin_network_QUIET "QUIET" ) - endif() - - # modulespec - if ( Bitcoin-Network_FIND_VERSION_COUNT EQUAL 0 ) - set( _bitcoin_network_MODULE_SPEC "libbitcoin-network" ) - else () - if ( Bitcoin-Network_FIND_VERSION_EXACT ) - set( _bitcoin_network_MODULE_SPEC_OP "=" ) - else () - set( _bitcoin_network_MODULE_SPEC_OP ">=" ) - endif() - - set( _bitcoin_network_MODULE_SPEC "libbitcoin-network ${_bitcoin_network_MODULE_SPEC_OP} ${Bitcoin-Network_FIND_VERSION}" ) - endif() - - pkg_check_modules( bitcoin_network ${_bitcoin_network_REQUIRED} ${_bitcoin_network_QUIET} "${_bitcoin_network_MODULE_SPEC}" ) - set( bitcoin_network_PKG "${_bitcoin_network_MODULE_SPEC}" ) -endif() diff --git a/install-cmake.sh b/install-cmake.sh index 2ee17f01..644d8d34 100755 --- a/install-cmake.sh +++ b/install-cmake.sh @@ -8,16 +8,6 @@ # Script to build and install libbitcoin-node. # # Script options: -# --with-icu Compile with International Components for Unicode. -# Since the addition of BIP-39 and later BIP-38 -# support, libbitcoin conditionally incorporates ICU -# to provide BIP-38 and BIP-39 passphrase -# normalization features. Currently -# libbitcoin-explorer is the only other library that -# accesses this feature, so if you do not intend to -# use passphrase normalization this dependency can -# be avoided. -# --build-icu Builds ICU libraries. # --build-boost Builds Boost libraries. # --build-dir= Location of downloaded and intermediate files. # --prefix= Library install location (defaults to /usr/local). @@ -64,11 +54,6 @@ BUILD_SRC_DIR="build-libbitcoin-node" PRESUMED_CI_PROJECT_PATH=$(pwd) -# ICU archive. -#------------------------------------------------------------------------------ -ICU_URL="https://github.com/unicode-org/icu/releases/download/release-78.2/icu4c-78.2-sources.tgz" -ICU_ARCHIVE="icu4c-78.2-sources.tgz" - # Boost archive. #------------------------------------------------------------------------------ BOOST_URL="https://archives.boost.io/release/1.86.0/source/boost_1_86_0.tar.bz2" @@ -226,16 +211,6 @@ display_help() display_message "Usage: ./install.sh [OPTION]..." display_message "Manage the installation of libbitcoin-node." display_message "Script options:" - display_message " --with-icu Compile with International Components for Unicode." - display_message " Since the addition of BIP-39 and later BIP-38 " - display_message " support, libbitcoin conditionally incorporates ICU " - display_message " to provide BIP-38 and BIP-39 passphrase " - display_message " normalization features. Currently " - display_message " libbitcoin-explorer is the only other library that " - display_message " accesses this feature, so if you do not intend to " - display_message " use passphrase normalization this dependency can " - display_message " be avoided." - display_message " --build-icu Build ICU libraries." display_message " --build-boost Build Boost libraries." display_message " --build-secp256k1 Build libsecp256k1 libraries." display_message " --build-dir= Location of downloaded and intermediate files." @@ -264,10 +239,8 @@ parse_command_line_options() (--disable-static) DISABLE_STATIC="yes";; # Common project options. - (--with-icu) WITH_ICU="yes";; # Custom build options. - (--build-icu) BUILD_ICU="yes";; (--build-boost) BUILD_BOOST="yes";; (--build-secp256k1) BUILD_SECP256K1="yes";; @@ -359,10 +332,10 @@ handle_custom_options() exit 1 elif [[ $DISABLE_NDEBUG ]]; then CUMULATIVE_FILTERED_ARGS="--disable-ndebug" - CUMULATIVE_FILTERED_ARGS_CMAKE="-Denable-ndebug=no" + CUMULATIVE_FILTERED_ARGS_CMAKE="-DCMAKE_BUILD_TYPE=Debug" else CUMULATIVE_FILTERED_ARGS="--enable-ndebug" - CUMULATIVE_FILTERED_ARGS_CMAKE="-Denable-ndebug=yes" + CUMULATIVE_FILTERED_ARGS_CMAKE="-DCMAKE_BUILD_TYPE=Release" fi # Process link declaration @@ -391,12 +364,6 @@ handle_custom_options() export CMAKE_LIBRARY_PATH="${PREFIX}/lib:${CMAKE_LIBRARY_PATH}" fi fi - - # Process ICU - if [[ $WITH_ICU ]]; then - CUMULATIVE_FILTERED_ARGS+=" --with-icu" - CUMULATIVE_FILTERED_ARGS_CMAKE+=" -Dwith-icu=yes" - fi } remove_build_options() @@ -413,6 +380,7 @@ remove_install_options() CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--enable-*/}") CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--disable-*/}") CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--prefix=*/}") + CONFIGURE_OPTIONS=("${CONFIGURE_OPTIONS[@]/--verbose=*/}") } set_prefix() @@ -471,8 +439,6 @@ display_configuration() display_message "CXXFLAGS : $CXXFLAGS" display_message "LDFLAGS : $LDFLAGS" display_message "LDLIBS : $LDLIBS" - display_message "WITH_ICU : $WITH_ICU" - display_message "BUILD_ICU : $BUILD_ICU" display_message "BUILD_BOOST : $BUILD_BOOST" display_message "BUILD_SECP256K1 : $BUILD_SECP256K1" display_message "BOOST_ROOT : $BOOST_ROOT" @@ -490,27 +456,6 @@ display_configuration() # Define build functions. #============================================================================== -# Because PKG_CONFIG_PATH doesn't get updated by Homebrew or MacPorts. -initialize_icu_packages() -{ - if [[ ($OS == Darwin) ]]; then - # Update PKG_CONFIG_PATH for ICU package installations on OSX. - # OSX provides libicucore.dylib with no pkgconfig and doesn't support - # renaming or important features, so we can't use that. - local HOMEBREW_USR_ICU_PKG_CONFIG="/usr/local/opt/icu4c/lib/pkgconfig" - local HOMEBREW_OPT_ICU_PKG_CONFIG="/opt/homebrew/opt/icu4c/lib/pkgconfig" - local MACPORTS_ICU_PKG_CONFIG="/opt/local/lib/pkgconfig" - - if [[ -d "$HOMEBREW_USR_ICU_PKG_CONFIG" ]]; then - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$HOMEBREW_USR_ICU_PKG_CONFIG" - elif [[ -d "$HOMEBREW_OPT_ICU_PKG_CONFIG" ]]; then - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$HOMEBREW_OPT_ICU_PKG_CONFIG" - elif [[ -d "$MACPORTS_ICU_PKG_CONFIG" ]]; then - export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$MACPORTS_ICU_PKG_CONFIG" - fi - fi -} - extract_from_tarball() { local TARGET_DIR=$1 @@ -580,23 +525,8 @@ build_from_tarball() local SAVE_LDFLAGS="$LDFLAGS" local SAVE_CPPFLAGS="$CPPFLAGS" - # For some platforms we need to set ICU pkg-config path. - # TODO: clean this up? - if [[ ! ($BUILD) ]]; then - if [[ $ARCHIVE == "$ICU_ARCHIVE" ]]; then - display_heading_message "Rationalize ICU detection." - initialize_icu_packages - fi - return - fi - display_heading_message "Preparing to build $ARCHIVE" - # Because ICU tools don't know how to locate internal dependencies. - if [[ ($ARCHIVE == "$ICU_ARCHIVE") ]]; then - export LDFLAGS="-L$PREFIX/lib $LDFLAGS" - fi - local TARGET="build-$ARCHIVE" push_directory "$TARGET" push_directory "$PUSH_DIR" @@ -711,15 +641,25 @@ cmake_tests() cmake_project_directory() { local PROJ_NAME=$1 - local JOBS=$2 - local TEST=$3 - shift 3 + local CMAKE_PATH=$2 + local JOBS=$3 + local TEST=$4 + shift 4 push_directory "$PROJ_NAME" local PROJ_CONFIG_DIR PROJ_CONFIG_DIR=$(pwd) - cmake -LA $@ builds/cmake + create_directory "build-cmake" + push_directory "build-cmake" + + VERBOSITY="" + if [[ $DISPLAY_VERBOSE ]]; then + VERBOSITY="-DCMAKE_VERBOSE_MAKEFILE=ON" + fi + + cmake ${VERBOSITY} -LA $@ "../${CMAKE_PATH}" + make_jobs "$JOBS" if [[ $TEST == true ]]; then @@ -728,17 +668,19 @@ cmake_project_directory() make install configure_links - pop_directory + pop_directory # build-cmake + pop_directory # PROJ_NAME } build_from_github_cmake() { local REPO=$1 - local JOBS=$2 - local TEST=$3 - local BUILD=$4 - local OPTIONS=$5 - shift 5 + local CMAKE_PATH=$2 + local JOBS=$3 + local TEST=$4 + local BUILD=$5 + local OPTIONS=$6 + shift 6 if [[ ! ($BUILD) || ($BUILD == "no") ]]; then return @@ -750,25 +692,9 @@ build_from_github_cmake() display_heading_message "Preparing to build $REPO" # Build the local repository clone. - cmake_project_directory "$REPO" "$JOBS" "$TEST" "${CONFIGURATION[@]}" + cmake_project_directory "$REPO" "$CMAKE_PATH" "$JOBS" "$TEST" "${CONFIGURATION[@]}" } -# Because boost ICU static lib detection assumes in incorrect ICU path. -circumvent_boost_icu_detection() -{ - # Boost expects a directory structure for ICU which is incorrect. - # Boost ICU discovery fails when using prefix, can't fix with -sICU_LINK, - # so we rewrite the two 'has_icu_test.cpp' files to always return success. - - local SUCCESS="int main() { return 0; }" - local REGEX_TEST="libs/regex/build/has_icu_test.cpp" - local LOCALE_TEST="libs/locale/build/has_icu_test.cpp" - - printf "%s" "$SUCCESS" > $REGEX_TEST - printf "%s" "$SUCCESS" > $LOCALE_TEST - - # display_message "Hack: ICU detection modified, will always indicate found." -} # Because boost doesn't support autoconfig and doesn't like empty settings. initialize_boost_configuration() @@ -791,33 +717,6 @@ initialize_boost_configuration() BOOST_LINKFLAGS="linkflags=$STDLIB_FLAG" fi } - -# Because boost doesn't use pkg-config. -# The hacks below are still required as of boost 1.72.0. -initialize_boost_icu_configuration() -{ - BOOST_ICU_ICONV="on" - BOOST_ICU_POSIX="on" - - if [[ $WITH_ICU ]]; then - # Restrict other locale options when compiling boost with icu. - BOOST_ICU_ICONV="off" - BOOST_ICU_POSIX="off" - - # Work around boost ICU static lib discovery bug. - circumvent_boost_icu_detection - - # Extract ICU prefix directory from package config variable. - ICU_PREFIX=$(pkg-config icu-i18n --variable=prefix) - - # Extract ICU libs from package config variables and augment with -ldl. - ICU_LIBS="$(pkg-config icu-i18n --libs) -ldl" - - # This is a hack for boost m4 scripts that fail with ICU dependency. - export BOOST_ICU_LIBS=("${ICU_LIBS[@]}") - fi -} - # Because boost doesn't use autoconfig. build_from_tarball_boost() { @@ -840,7 +739,6 @@ build_from_tarball_boost() push_directory "$TARGET" initialize_boost_configuration - initialize_boost_icu_configuration guessed_toolset=`./tools/build/src/engine/build.sh --guess-toolset` CXXFLAGS="-w" ./tools/build/src/engine/build.sh ${guessed_toolset} --cxxflags="-w" @@ -859,11 +757,8 @@ build_from_tarball_boost() display_message "boost cxxflags : $BOOST_CXXFLAGS" display_message "boost linkflags : $BOOST_LINKFLAGS" display_message "link : $BOOST_LINK" - display_message "boost.locale.iconv : $BOOST_ICU_ICONV" - display_message "boost.locale.posix : $BOOST_ICU_POSIX" display_message "-sNO_BZIP2 : 1" display_message "-sNO_ZSTD : 1" - display_message "-sICU_PATH : $ICU_PREFIX" # display_message "-sICU_LINK : " "${ICU_LIBS[*]}" display_message "-j : $JOBS" display_message "-d0 : [supress informational messages]" @@ -876,8 +771,7 @@ build_from_tarball_boost() ./bootstrap.sh \ "--with-bjam=./b2" \ - "--prefix=$PREFIX" \ - "--with-icu=$ICU_PREFIX" + "--prefix=$PREFIX" # boost_regex: # As of boost 1.72.0 the ICU_LINK symbol is no longer supported and @@ -894,11 +788,8 @@ build_from_tarball_boost() "$BOOST_LINKFLAGS" \ "link=$BOOST_LINK" \ "warnings=off" \ - "boost.locale.iconv=$BOOST_ICU_ICONV" \ - "boost.locale.posix=$BOOST_ICU_POSIX" \ "-sNO_BZIP2=1" \ "-sNO_ZSTD=1" \ - "-sICU_PATH=$ICU_PREFIX" \ "-j $JOBS" \ "-d0" \ "-q" \ @@ -916,11 +807,6 @@ build_from_tarball_boost() #============================================================================== build_all() { - unpack_from_tarball "$ICU_ARCHIVE" "$ICU_URL" gzip "$BUILD_ICU" - local SAVE_CPPFLAGS="$CPPFLAGS" - export CPPFLAGS="$CPPFLAGS ${ICU_FLAGS[@]}" - build_from_tarball "$ICU_ARCHIVE" source "$PARALLEL" "$BUILD_ICU" "${ICU_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS - export CPPFLAGS=$SAVE_CPPFLAGS unpack_from_tarball "$BOOST_ARCHIVE" "$BOOST_URL" bzip2 "$BUILD_BOOST" local SAVE_CPPFLAGS="$CPPFLAGS" export CPPFLAGS="$CPPFLAGS ${BOOST_FLAGS[@]}" @@ -929,32 +815,32 @@ build_all() create_from_github bitcoin-core secp256k1 ${SECP256K1_BRANCH} "$BUILD_SECP256K1" local SAVE_CPPFLAGS="$CPPFLAGS" export CPPFLAGS="$CPPFLAGS ${SECP256K1_FLAGS[@]}" - build_from_github secp256k1 "$PARALLEL" false "$BUILD_SECP256K1" "${SECP256K1_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS + build_from_github_cmake secp256k1 "." "$PARALLEL" false "$BUILD_SECP256K1" "${SECP256K1_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" export CPPFLAGS=$SAVE_CPPFLAGS create_from_github libbitcoin libbitcoin-system ${BITCOIN_SYSTEM_BRANCH} "yes" local SAVE_CPPFLAGS="$CPPFLAGS" export CPPFLAGS="$CPPFLAGS ${BITCOIN_SYSTEM_FLAGS[@]}" - build_from_github_cmake libbitcoin-system "$PARALLEL" false "yes" "${BITCOIN_SYSTEM_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" + build_from_github_cmake libbitcoin-system "builds/cmake" "$PARALLEL" false "yes" "${BITCOIN_SYSTEM_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" export CPPFLAGS=$SAVE_CPPFLAGS create_from_github libbitcoin libbitcoin-network ${BITCOIN_NETWORK_BRANCH} "yes" local SAVE_CPPFLAGS="$CPPFLAGS" export CPPFLAGS="$CPPFLAGS ${BITCOIN_NETWORK_FLAGS[@]}" - build_from_github_cmake libbitcoin-network "$PARALLEL" false "yes" "${BITCOIN_NETWORK_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" + build_from_github_cmake libbitcoin-network "builds/cmake" "$PARALLEL" false "yes" "${BITCOIN_NETWORK_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" export CPPFLAGS=$SAVE_CPPFLAGS create_from_github libbitcoin libbitcoin-database ${BITCOIN_DATABASE_BRANCH} "yes" local SAVE_CPPFLAGS="$CPPFLAGS" export CPPFLAGS="$CPPFLAGS ${BITCOIN_DATABASE_FLAGS[@]}" - build_from_github_cmake libbitcoin-database "$PARALLEL" false "yes" "${BITCOIN_DATABASE_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" + build_from_github_cmake libbitcoin-database "builds/cmake" "$PARALLEL" false "yes" "${BITCOIN_DATABASE_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" export CPPFLAGS=$SAVE_CPPFLAGS local SAVE_CPPFLAGS="$CPPFLAGS" export CPPFLAGS="$CPPFLAGS ${BITCOIN_NODE_FLAGS[@]}" if [[ ! ($CI == true) ]]; then create_from_github libbitcoin libbitcoin-node ${BITCOIN_NODE_BRANCH} "yes" - build_from_github_cmake libbitcoin-node "$PARALLEL" true "yes" "${BITCOIN_NODE_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" + build_from_github_cmake libbitcoin-node "builds/cmake" "$PARALLEL" true "yes" "${BITCOIN_NODE_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" else push_directory "$PRESUMED_CI_PROJECT_PATH" push_directory ".." - build_from_github_cmake libbitcoin-node "$PARALLEL" true "yes" "${BITCOIN_NODE_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" + build_from_github_cmake libbitcoin-node "builds/cmake" "$PARALLEL" true "yes" "${BITCOIN_NODE_OPTIONS[@]}" $CUMULATIVE_FILTERED_ARGS_CMAKE "$@" pop_directory pop_directory fi @@ -982,11 +868,6 @@ remove_install_options # Define build flags. #============================================================================== -# Define icu flags. -#------------------------------------------------------------------------------ -ICU_FLAGS=( -"-w") - # Define boost flags. #------------------------------------------------------------------------------ BOOST_FLAGS=( @@ -1000,19 +881,6 @@ SECP256K1_FLAGS=( # Define build options. #============================================================================== -# Define icu options. -#------------------------------------------------------------------------------ -ICU_OPTIONS=( -"--enable-draft" \ -"--enable-rpath" \ -"--enable-tools" \ -"--disable-extras" \ -"--disable-icuio" \ -"--disable-layout" \ -"--disable-layoutex" \ -"--disable-tests" \ -"--disable-samples") - # Define boost options. #------------------------------------------------------------------------------ BOOST_OPTIONS=( @@ -1027,31 +895,31 @@ BOOST_OPTIONS=( # Define secp256k1 options. #------------------------------------------------------------------------------ SECP256K1_OPTIONS=( -"--disable-tests" \ -"--enable-experimental" \ -"--enable-module-recovery" \ -"--enable-module-schnorrsig") +"-DSECP256K1_BUILD_TESTS=OFF" \ +"-DSECP256K1_EXPERIMENTAL=ON" \ +"-DSECP256K1_ENABLE_MODULE_RECOVERY=ON" \ +"-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON") # Define bitcoin-system options. #------------------------------------------------------------------------------ BITCOIN_SYSTEM_OPTIONS=( -"-Dwith-tests=no" \ -"-Dwith-examples=no" \ +"-Dwith-tests:BOOL=OFF" \ +"-Dwith-examples:BOOL=OFF" \ "${with_boost}" \ "${with_pkgconfigdir}") # Define bitcoin-network options. #------------------------------------------------------------------------------ BITCOIN_NETWORK_OPTIONS=( -"-Dwith-tests=no" \ +"-Dwith-tests:BOOL=OFF" \ "${with_boost}" \ "${with_pkgconfigdir}") # Define bitcoin-database options. #------------------------------------------------------------------------------ BITCOIN_DATABASE_OPTIONS=( -"-Dwith-tests=no" \ -"-Dwith-tools=no" \ +"-Dwith-tests:BOOL=OFF" \ +"-Dwith-tools:BOOL=OFF" \ "${with_boost}" \ "${with_pkgconfigdir}") diff --git a/install-cmakepresets.sh b/install-cmakepresets.sh index f96c2f52..e2e7130f 100755 --- a/install-cmakepresets.sh +++ b/install-cmakepresets.sh @@ -8,16 +8,6 @@ # Script to build and install libbitcoin-node. # # Script options: -# --with-icu Compile with International Components for Unicode. -# Since the addition of BIP-39 and later BIP-38 -# support, libbitcoin conditionally incorporates ICU -# to provide BIP-38 and BIP-39 passphrase -# normalization features. Currently -# libbitcoin-explorer is the only other library that -# accesses this feature, so if you do not intend to -# use passphrase normalization this dependency can -# be avoided. -# --build-icu Builds ICU libraries. # --build-boost Builds Boost libraries. # --build-dir= Location of downloaded and intermediate files. # --preset=