Skip to content

Commit

Permalink
fixup! cmake: Build bitcoind executable
Browse files Browse the repository at this point in the history
Add `BOOST_NO_CXX98_FUNCTION_BASE` definition when needed.

This mirrors the master branch behavior and fixes native build on macOS
with Homebrew's `boost@1.76`.
  • Loading branch information
hebasto committed Jun 3, 2024
1 parent 6230d47 commit 3f4a57d
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion cmake/module/AddBoostIfNeeded.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,30 @@ function(add_boost_if_needed)
)
endif()

# Prevent use of std::unary_function, which was removed in C++17,
# and will generate warnings with newer compilers for Boost
# older than 1.80.
# See: https://github.com/boostorg/config/pull/430.
set(CMAKE_REQUIRED_DEFINITIONS -DBOOST_NO_CXX98_FUNCTION_BASE)
set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIR})
include(CMakePushCheckState)
cmake_push_check_state()
include(TryAppendCXXFlags)
set(CMAKE_REQUIRED_FLAGS ${working_compiler_werror_flag})
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
check_cxx_source_compiles("
#include <boost/config.hpp>
" NO_DIAGNOSTICS_BOOST_NO_CXX98_FUNCTION_BASE
)
cmake_pop_check_state()
if(NO_DIAGNOSTICS_BOOST_NO_CXX98_FUNCTION_BASE)
target_compile_definitions(Boost::headers INTERFACE
BOOST_NO_CXX98_FUNCTION_BASE
)
endif()

if(BUILD_TESTS)
include(CheckCXXSourceCompiles)
set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIR})
check_cxx_source_compiles("
#define BOOST_TEST_MAIN
#include <boost/test/included/unit_test.hpp>
Expand Down

0 comments on commit 3f4a57d

Please sign in to comment.