Skip to content

Commit f2dbb17

Browse files
committed
[FIXUP] for "cmake: Build test_bitcoin executable"
The vcpkg package manager has a separated `boost-test` package, and it is more robust to test its headers explicitly.
1 parent 91d7327 commit f2dbb17

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

cmake/module/AddBoostIfNeeded.cmake

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,28 @@ function(add_boost_if_needed)
2828
add_library(Boost::headers ALIAS Boost::boost)
2929
endif()
3030

31+
if(BUILD_TESTS)
32+
include(CheckCXXSourceCompiles)
33+
set(CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIR})
34+
check_cxx_source_compiles("
35+
#define BOOST_TEST_MAIN
36+
#include <boost/test/included/unit_test.hpp>
37+
" HAVE_BOOST_INCLUDED_UNIT_TEST_H
38+
)
39+
if(NOT HAVE_BOOST_INCLUDED_UNIT_TEST_H)
40+
message(FATAL_ERROR "Building test_bitcoin executable requested but boost/test/included/unit_test.hpp header not available.")
41+
endif()
42+
43+
check_cxx_source_compiles("
44+
#define BOOST_TEST_MAIN
45+
#include <boost/test/included/unit_test.hpp>
46+
#include <boost/test/unit_test.hpp>
47+
" HAVE_BOOST_UNIT_TEST_H
48+
)
49+
if(NOT HAVE_BOOST_UNIT_TEST_H)
50+
message(FATAL_ERROR "Building test_bitcoin executable requested but boost/test/unit_test.hpp header not available.")
51+
endif()
52+
endif()
53+
3154
mark_as_advanced(Boost_INCLUDE_DIR)
3255
endfunction()

0 commit comments

Comments
 (0)