diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cbb062a9..f73d7e8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -119,7 +119,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Prepare toolchain [generic] run: | @@ -140,7 +140,7 @@ jobs: shell: bash run: | WORKSPACE_SUBPATH="${GITHUB_WORKSPACE%libbitcoin-blockchain}" - echo "LIBBITCOIN_SRC_PATH=$WORKSPACE_SUBPATH" >> $GITHUB_ENV + echo "LIBBITCOIN_SRC_PATH=${WORKSPACE_SUBPATH}" >> $GITHUB_ENV if [[ ${{ matrix.assert }} == 'ndebug' ]]; then echo "ASSERT_NDEBUG=--enable-ndebug" >> $GITHUB_ENV else @@ -152,7 +152,7 @@ jobs: echo "LINKAGE=--disable-shared" >> $GITHUB_ENV fi if [[ ${{ matrix.link }} == 'dynamic' ]]; then - echo "LDFLAGS=-Wl,-rpath,$WORKSPACE_SUBPATH/prefix/lib" >> $GITHUB_ENV + echo "LDFLAGS=-Wl,-rpath,${WORKSPACE_SUBPATH}prefix/lib" >> $GITHUB_ENV fi - name: Display Compiler details @@ -349,7 +349,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Prepare toolchain [generic] run: | @@ -370,7 +370,7 @@ jobs: shell: bash run: | WORKSPACE_SUBPATH="${GITHUB_WORKSPACE%libbitcoin-blockchain}" - echo "LIBBITCOIN_SRC_PATH=$WORKSPACE_SUBPATH" >> $GITHUB_ENV + echo "LIBBITCOIN_SRC_PATH=${WORKSPACE_SUBPATH}" >> $GITHUB_ENV if [[ ${{ matrix.packager }} == 'brew' ]]; then echo "CMAKE_LIBRARY_PATH=/usr/local/lib" >> $GITHUB_ENV fi @@ -385,7 +385,7 @@ jobs: echo "LINKAGE=--disable-shared" >> $GITHUB_ENV fi if [[ ${{ matrix.link }} == 'dynamic' ]]; then - echo "LDFLAGS=-Wl,-rpath,$WORKSPACE_SUBPATH/prefix/lib" >> $GITHUB_ENV + echo "LDFLAGS=-Wl,-rpath,${WORKSPACE_SUBPATH}prefix/lib" >> $GITHUB_ENV fi - name: Display Compiler details @@ -550,7 +550,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Prepare toolchain [generic] run: | @@ -571,7 +571,7 @@ jobs: shell: bash run: | WORKSPACE_SUBPATH="${GITHUB_WORKSPACE%libbitcoin-blockchain}" - echo "LIBBITCOIN_SRC_PATH=$WORKSPACE_SUBPATH" >> $GITHUB_ENV + echo "LIBBITCOIN_SRC_PATH=${WORKSPACE_SUBPATH}" >> $GITHUB_ENV if [[ ${{ matrix.packager }} == 'brew' ]]; then echo "CMAKE_LIBRARY_PATH=/usr/local/lib" >> $GITHUB_ENV fi @@ -586,7 +586,7 @@ jobs: echo "LINKAGE=--disable-shared" >> $GITHUB_ENV fi if [[ ${{ matrix.link }} == 'dynamic' ]]; then - echo "LDFLAGS=-Wl,-rpath,$WORKSPACE_SUBPATH/prefix/${{ matrix.preset }}/lib" >> $GITHUB_ENV + echo "LDFLAGS=-Wl,-rpath,${WORKSPACE_SUBPATH}prefix/${{ matrix.preset }}/lib" >> $GITHUB_ENV fi - name: Display Compiler details @@ -712,7 +712,7 @@ jobs: msbuild-architecture: x64 - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Initialize SDK shell: powershell diff --git a/builds/cmake/CMakeLists.txt b/builds/cmake/CMakeLists.txt index 505717d3..1e005051 100644 --- a/builds/cmake/CMakeLists.txt +++ b/builds/cmake/CMakeLists.txt @@ -7,7 +7,7 @@ # libbitcoin-blockchain project configuration. #------------------------------------------------------------------------------ -cmake_minimum_required(VERSION 3.5 FATAL_ERROR) +cmake_minimum_required(VERSION 3.18 FATAL_ERROR) project(libbitcoin-blockchain LANGUAGES C CXX) @@ -18,6 +18,7 @@ include(CheckIncludeFiles) include(CheckSymbolExists) include(CheckCXXCompilerFlag) include(CheckCXXSourceCompiles) +include(CheckLinkerFlag) set_property(GLOBAL PROPERTY USE_FOLDERS ON) @@ -162,11 +163,7 @@ find_package( Boost 1.73.0 REQUIRED COMPONENTS set( boost_unit_test_framework_LIBS "-lboost_unit_test_framework" ) -if (enable-ndebug) - set( Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR_DEBUG}" ) -else () - set( Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR_RELEASE}" ) -endif() +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}" ) @@ -181,46 +178,75 @@ if (with-consensus) find_package( Bitcoin-Consensus 3.8.0 REQUIRED ) endif() -# Define project common includes directories +# Define project common includes for build. #------------------------------------------------------------------------------ if (BUILD_SHARED_LIBS) - include_directories( SYSTEM - ${bitcoin_database_INCLUDE_DIRS} - ${bitcoin_consensus_INCLUDE_DIRS} ) + set( bitcoin_database_FOR_BUILD_INCLUDE_DIRS ${bitcoin_database_INCLUDE_DIRS} CACHE STRING "Placeholder" ) + set( bitcoin_consensus_FOR_BUILD_INCLUDE_DIRS ${bitcoin_consensus_INCLUDE_DIRS} CACHE STRING "Placeholder" ) else() - include_directories( SYSTEM - ${bitcoin_database_STATIC_INCLUDE_DIRS} - ${bitcoin_consensus_STATIC_INCLUDE_DIRS} ) + set( bitcoin_database_FOR_BUILD_INCLUDE_DIRS ${bitcoin_database_STATIC_INCLUDE_DIRS} CACHE STRING "Placeholder" ) + set( bitcoin_consensus_FOR_BUILD_INCLUDE_DIRS ${bitcoin_consensus_STATIC_INCLUDE_DIRS} CACHE STRING "Placeholder" ) endif() -# Define project common library directories +# Define project common includes directories +#------------------------------------------------------------------------------ +include_directories( SYSTEM + ${bitcoin_database_FOR_BUILD_INCLUDE_DIRS} + ${bitcoin_consensus_FOR_BUILD_INCLUDE_DIRS} ) + +# Define project common library directories for build. #------------------------------------------------------------------------------ if (BUILD_SHARED_LIBS) - link_directories( - ${bitcoin_database_LIBRARY_DIRS} - ${bitcoin_consensus_LIBRARY_DIRS} ) + set( bitcoin_database_FOR_BUILD_LIBRARY_DIRS ${bitcoin_database_LIBRARY_DIRS} CACHE STRING "Placeholder" ) + set( bitcoin_consensus_FOR_BUILD_LIBRARY_DIRS ${bitcoin_consensus_LIBRARY_DIRS} CACHE STRING "Placeholder" ) else() - link_directories( - ${bitcoin_database_STATIC_LIBRARY_DIRS} - ${bitcoin_consensus_STATIC_LIBRARY_DIRS} ) + set( bitcoin_database_FOR_BUILD_LIBRARY_DIRS ${bitcoin_database_STATIC_LIBRARY_DIRS} CACHE STRING "Placeholder" ) + set( bitcoin_consensus_FOR_BUILD_LIBRARY_DIRS ${bitcoin_consensus_STATIC_LIBRARY_DIRS} CACHE STRING "Placeholder" ) +endif() + +# Define project common library directories +#------------------------------------------------------------------------------ +link_directories( + ${bitcoin_database_FOR_BUILD_LIBRARY_DIRS} + ${bitcoin_consensus_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 project common libraries/linker flags. + +# Define common library usage for build. #------------------------------------------------------------------------------ if (BUILD_SHARED_LIBS) - link_libraries( - "-fstack-protector" - "-fstack-protector-all" - ${bitcoin_database_LIBRARIES} - ${bitcoin_consensus_LIBRARIES} ) + set( bitcoin_database_FOR_BUILD_LIBRARIES ${bitcoin_database_LIBRARIES} CACHE STRING "Placeholder" ) + set( bitcoin_consensus_FOR_BUILD_LIBRARIES ${bitcoin_consensus_LIBRARIES} CACHE STRING "Placeholder" ) else() - link_libraries( - "-fstack-protector" - "-fstack-protector-all" - ${bitcoin_database_STATIC_LIBRARIES} - ${bitcoin_consensus_STATIC_LIBRARIES} ) + set( bitcoin_database_FOR_BUILD_LIBRARIES ${bitcoin_database_STATIC_LIBRARIES} CACHE STRING "Placeholder" ) + set( bitcoin_consensus_FOR_BUILD_LIBRARIES ${bitcoin_consensus_STATIC_LIBRARIES} CACHE STRING "Placeholder" ) endif() +# Define project common libraries. +#------------------------------------------------------------------------------ +link_libraries( + ${bitcoin_database_FOR_BUILD_LIBRARIES} + ${bitcoin_consensus_FOR_BUILD_LIBRARIES} ) + # Define ${CANONICAL_LIB_NAME} project. #------------------------------------------------------------------------------ add_library( ${CANONICAL_LIB_NAME} @@ -241,35 +267,42 @@ add_library( ${CANONICAL_LIB_NAME} "../../src/validate/validate_input.cpp" "../../src/validate/validate_transaction.cpp" ) -# ${CANONICAL_LIB_NAME} project specific include directories. +# ${CANONICAL_LIB_NAME} project specific include directory normalization for build. #------------------------------------------------------------------------------ if (BUILD_SHARED_LIBS) - target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE - "../../include" - ${bitcoin_database_INCLUDE_DIRS} - ${bitcoin_consensus_INCLUDE_DIRS} ) + set( bitcoin_database_FOR_BUILD_INCLUDE_DIRS ${bitcoin_database_INCLUDE_DIRS} CACHE STRING "Placeholder" ) + set( bitcoin_consensus_FOR_BUILD_INCLUDE_DIRS ${bitcoin_consensus_INCLUDE_DIRS} CACHE STRING "Placeholder" ) else() - target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE - "../../include" - ${bitcoin_database_STATIC_INCLUDE_DIRS} - ${bitcoin_consensus_STATIC_INCLUDE_DIRS} ) + set( bitcoin_database_FOR_BUILD_INCLUDE_DIRS ${bitcoin_database_STATIC_INCLUDE_DIRS} CACHE STRING "Placeholder" ) + set( bitcoin_consensus_FOR_BUILD_INCLUDE_DIRS ${bitcoin_consensus_STATIC_INCLUDE_DIRS} CACHE STRING "Placeholder" ) endif() +# ${CANONICAL_LIB_NAME} project specific include directories. +#------------------------------------------------------------------------------ +target_include_directories( ${CANONICAL_LIB_NAME} PRIVATE + "../../include" + ${bitcoin_database_FOR_BUILD_INCLUDE_DIRS} + ${bitcoin_consensus_FOR_BUILD_INCLUDE_DIRS} ) + target_include_directories( ${CANONICAL_LIB_NAME} PUBLIC "../../include" ) -# ${CANONICAL_LIB_NAME} project specific libraries/linker flags. +# ${CANONICAL_LIB_NAME} project specific libraries noramalization for build. #------------------------------------------------------------------------------ if (BUILD_SHARED_LIBS) - target_link_libraries( ${CANONICAL_LIB_NAME} - ${bitcoin_database_LIBRARIES} - ${bitcoin_consensus_LIBRARIES} ) + set( bitcoin_database_FOR_BUILD_LIBRARIES ${bitcoin_database_LIBRARIES} CACHE STRING "Placeholder" ) + set( bitcoin_consensus_FOR_BUILD_LIBRARIES ${bitcoin_consensus_LIBRARIES} CACHE STRING "Placeholder" ) else() - target_link_libraries( ${CANONICAL_LIB_NAME} - ${bitcoin_database_STATIC_LIBRARIES} - ${bitcoin_consensus_STATIC_LIBRARIES} ) + set( bitcoin_database_FOR_BUILD_LIBRARIES ${bitcoin_database_STATIC_LIBRARIES} CACHE STRING "Placeholder" ) + set( bitcoin_consensus_FOR_BUILD_LIBRARIES ${bitcoin_consensus_STATIC_LIBRARIES} CACHE STRING "Placeholder" ) endif() +# ${CANONICAL_LIB_NAME} project specific libraries/linker flags. +#------------------------------------------------------------------------------ +target_link_libraries( ${CANONICAL_LIB_NAME} + ${bitcoin_database_FOR_BUILD_LIBRARIES} + ${bitcoin_consensus_FOR_BUILD_LIBRARIES} ) + # Define libbitcoin-blockchain-test project. #------------------------------------------------------------------------------ if (with-tests) diff --git a/configure.ac b/configure.ac index f4ba720b..53c7e7d3 100644 --- a/configure.ac +++ b/configure.ac @@ -230,6 +230,12 @@ AS_CASE([${CC}], [*clang*], [AX_CHECK_COMPILE_FLAG([-Wno-mismatched-tags], [CXXFLAGS="$CXXFLAGS -Wno-mismatched-tags"])]) +# Address -undefined dynamic_lookup MacOS error. +#------------------------------------------------------------------------------ +AS_CASE([${CC}], [*], + [AX_CHECK_LINK_FLAG([-no_fixup_chains], + [LDFLAGS="$LDFLAGS -no_fixup_chains"])]) + # Protect stack. #------------------------------------------------------------------------------ AS_CASE([${CC}], [*],