Skip to content

Commit 3f4a57d

Browse files
committed
fixup! cmake: Build bitcoind executable
Add `BOOST_NO_CXX98_FUNCTION_BASE` definition when needed. This mirrors the master branch behavior and fixes native build on macOS with Homebrew's `[email protected]`.
1 parent 6230d47 commit 3f4a57d

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

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)