Skip to content

Commit 0e6def0

Browse files
committed
Merge #219: cmake: Add BOOST_NO_CXX98_FUNCTION_BASE definition when needed
bf49bde fixup! ci: Migrate CI scripts to CMake (Hennadii Stepanov) 3f4a57d fixup! cmake: Build `bitcoind` executable (Hennadii Stepanov) Pull request description: This PR mirrors the master branch behaviour. ACKs for top commit: m3dwards: ACK bf49bde Tree-SHA512: 2ac23cd3a2d28febd357b3ea6c2631dbb9a5edfbef12330a74812b0edf351d15be05e6afbcaec44c455059de8539f23543bbfb0c5cd3bf0b546e5a40d746f26c
2 parents efc356b + bf49bde commit 0e6def0

File tree

2 files changed

+37
-10
lines changed

2 files changed

+37
-10
lines changed

.github/workflows/cmake.yml

+15-9
Original file line numberDiff line numberDiff line change
@@ -520,17 +520,23 @@ jobs:
520520
521521
522522
macos-native:
523-
name: '${{ matrix.os.name }}, ${{ matrix.xcode.name }}'
524-
runs-on: ${{ matrix.os.os }}
523+
name: '${{ matrix.conf.name }}, ${{ matrix.xcode.name }}'
524+
runs-on: ${{ matrix.conf.os }}
525525

526526
strategy:
527527
fail-fast: false
528528
matrix:
529-
os:
529+
conf:
530530
- name: 'macOS 13 native, x86_64'
531531
os: macos-13
532+
boost_package: 'boost'
532533
- name: 'macOS 14 native, arm64'
533534
os: macos-14
535+
boost_package: 'boost'
536+
- name: 'macOS 14 native, arm64, Boost 1.76'
537+
os: macos-14
538+
boost_package: '[email protected]'
539+
build_options: '-DBoost_INCLUDE_DIR=/opt/homebrew/opt/[email protected]/include'
534540
xcode:
535541
- name: 'Xcode 15.2'
536542
id: 'xcode-15.2'
@@ -546,7 +552,7 @@ jobs:
546552
clang --version
547553
548554
- name: Workaround for Homebrew python link
549-
if: matrix.os.os == 'macos-13'
555+
if: matrix.conf.os == 'macos-13'
550556
env:
551557
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
552558
run: |
@@ -556,7 +562,7 @@ jobs:
556562
env:
557563
HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK: 1
558564
run: |
559-
brew install ccache cmake pkg-config boost libevent berkeley-db@4 qt@5 qrencode libnatpmp miniupnpc zeromq tree
565+
brew install ccache cmake pkg-config ${{ matrix.conf.boost_package }} libevent berkeley-db@4 qt@5 qrencode libnatpmp miniupnpc zeromq tree
560566
echo "CCACHE_DIR=${{ runner.temp }}/ccache" >> "$GITHUB_ENV"
561567
562568
- name: CMake version
@@ -569,12 +575,12 @@ jobs:
569575
id: ccache-cache
570576
with:
571577
path: ${{ env.CCACHE_DIR }}
572-
key: ${{ matrix.os.os }}-${{ matrix.xcode.id }}-ccache-${{ github.run_id }}
573-
restore-keys: ${{ matrix.os.os }}-${{ matrix.xcode.id }}-ccache-
578+
key: ${{ matrix.conf.os }}-${{ matrix.xcode.id }}-ccache-${{ github.run_id }}
579+
restore-keys: ${{ matrix.conf.os }}-${{ matrix.xcode.id }}-ccache-
574580

575581
- name: Generate build system
576582
run: |
577-
cmake -B build --preset ci-darwin
583+
cmake -B build --preset ci-darwin ${{ matrix.conf.build_options }}
578584
579585
- name: Build
580586
env:
@@ -593,7 +599,7 @@ jobs:
593599
if: github.event_name != 'pull_request' && steps.ccache-cache.outputs.cache-hit != 'true'
594600
with:
595601
path: ${{ env.CCACHE_DIR }}
596-
key: ${{ matrix.os.os }}-${{ matrix.xcode.id }}-ccache-${{ github.run_id }}
602+
key: ${{ matrix.conf.os }}-${{ matrix.xcode.id }}-ccache-${{ github.run_id }}
597603

598604
- name: Test
599605
run: |

cmake/module/AddBoostIfNeeded.cmake

+22-1
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,30 @@ function(add_boost_if_needed)
3232
)
3333
endif()
3434

35+
# Prevent use of std::unary_function, which was removed in C++17,
36+
# and will generate warnings with newer compilers for Boost
37+
# older than 1.80.
38+
# See: https://github.com/boostorg/config/pull/430.
39+
set(CMAKE_REQUIRED_DEFINITIONS -DBOOST_NO_CXX98_FUNCTION_BASE)
40+
set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIR})
41+
include(CMakePushCheckState)
42+
cmake_push_check_state()
43+
include(TryAppendCXXFlags)
44+
set(CMAKE_REQUIRED_FLAGS ${working_compiler_werror_flag})
45+
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
46+
check_cxx_source_compiles("
47+
#include <boost/config.hpp>
48+
" NO_DIAGNOSTICS_BOOST_NO_CXX98_FUNCTION_BASE
49+
)
50+
cmake_pop_check_state()
51+
if(NO_DIAGNOSTICS_BOOST_NO_CXX98_FUNCTION_BASE)
52+
target_compile_definitions(Boost::headers INTERFACE
53+
BOOST_NO_CXX98_FUNCTION_BASE
54+
)
55+
endif()
56+
3557
if(BUILD_TESTS)
3658
include(CheckCXXSourceCompiles)
37-
set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIR})
3859
check_cxx_source_compiles("
3960
#define BOOST_TEST_MAIN
4061
#include <boost/test/included/unit_test.hpp>

0 commit comments

Comments
 (0)