@@ -29,17 +29,8 @@ function(add_boost_if_needed)
29
29
endif ()
30
30
endif ()
31
31
32
- # We cannot rely on find_package(Boost ...) to work properly without
33
- # Boost_NO_BOOST_CMAKE set until we require a more recent Boost because
34
- # upstream did not ship proper CMake files until 1.82.0.
35
- # Until then, we rely on CMake's FindBoost module.
36
- # See: https://cmake.org/cmake/help/latest/policy/CMP0167.html
37
- if (POLICY CMP0167 )
38
- cmake_policy (SET CMP0167 OLD )
39
- endif ()
40
- set (Boost_NO_BOOST_CMAKE ON )
41
- find_package (Boost 1.73.0 REQUIRED )
42
- mark_as_advanced (Boost_INCLUDE_DIR )
32
+ find_package (Boost 1.73.0 REQUIRED CONFIG )
33
+ mark_as_advanced (Boost_INCLUDE_DIR boost_headers_DIR )
43
34
set_target_properties (Boost::headers PROPERTIES IMPORTED_GLOBAL TRUE )
44
35
target_compile_definitions (Boost::headers INTERFACE
45
36
# We don't use multi_index serialization.
@@ -57,34 +48,24 @@ function(add_boost_if_needed)
57
48
# older than 1.80.
58
49
# See: https://github.com/boostorg/config/pull/430.
59
50
set (CMAKE_REQUIRED_DEFINITIONS -DBOOST_NO_CXX98_FUNCTION_BASE )
60
- set (CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIR} )
61
- include (CMakePushCheckState )
62
- cmake_push_check_state ()
63
- include (TryAppendCXXFlags )
51
+ get_target_property (CMAKE_REQUIRED_INCLUDES Boost::headers INTERFACE_INCLUDE_DIRECTORIES )
64
52
set (CMAKE_REQUIRED_FLAGS ${working_compiler_werror_flag} )
65
53
set (CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY )
54
+ include (CheckCXXSourceCompiles )
66
55
check_cxx_source_compiles ("
67
56
#include <boost/config.hpp>
68
57
" NO_DIAGNOSTICS_BOOST_NO_CXX98_FUNCTION_BASE
69
58
)
70
- cmake_pop_check_state ()
71
59
if (NO_DIAGNOSTICS_BOOST_NO_CXX98_FUNCTION_BASE )
72
60
target_compile_definitions (Boost::headers INTERFACE
73
61
BOOST_NO_CXX98_FUNCTION_BASE
74
62
)
75
- else ()
76
- set (CMAKE_REQUIRED_DEFINITIONS )
77
63
endif ()
78
64
79
65
# Some package managers, such as vcpkg, vendor Boost.Test separately
80
66
# from the rest of the headers, so we have to check for it individually.
81
67
if (BUILD_TESTS AND DEFINED VCPKG_TARGET_TRIPLET )
82
- list (APPEND CMAKE_REQUIRED_DEFINITIONS -DBOOST_TEST_NO_MAIN )
83
- include (CheckIncludeFileCXX )
84
- check_include_file_cxx (boost/test/included/unit_test.hpp HAVE_BOOST_INCLUDED_UNIT_TEST_H )
85
- if (NOT HAVE_BOOST_INCLUDED_UNIT_TEST_H )
86
- message (FATAL_ERROR "Building test_bitcoin executable requested but boost/test/included/unit_test.hpp header not available." )
87
- endif ()
68
+ find_package (boost_included_unit_test_framework ${Boost_VERSION} EXACT REQUIRED CONFIG )
88
69
endif ()
89
70
90
71
endfunction ()
0 commit comments