Skip to content

Commit

Permalink
[FIXUP] for "cmake: Build test_bitcoin executable"
Browse files Browse the repository at this point in the history
The vcpkg package manager has a separated `boost-test` package, and it
is more robust to test its headers explicitly.
  • Loading branch information
hebasto committed Jul 10, 2023
1 parent 91d7327 commit f2dbb17
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions cmake/module/AddBoostIfNeeded.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,28 @@ function(add_boost_if_needed)
add_library(Boost::headers ALIAS Boost::boost)
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>
" HAVE_BOOST_INCLUDED_UNIT_TEST_H
)
if(NOT HAVE_BOOST_INCLUDED_UNIT_TEST_H)
message(FATAL_ERROR "Building test_bitcoin executable requested but boost/test/included/unit_test.hpp header not available.")
endif()

check_cxx_source_compiles("
#define BOOST_TEST_MAIN
#include <boost/test/included/unit_test.hpp>
#include <boost/test/unit_test.hpp>
" HAVE_BOOST_UNIT_TEST_H
)
if(NOT HAVE_BOOST_UNIT_TEST_H)
message(FATAL_ERROR "Building test_bitcoin executable requested but boost/test/unit_test.hpp header not available.")
endif()
endif()

mark_as_advanced(Boost_INCLUDE_DIR)
endfunction()

0 comments on commit f2dbb17

Please sign in to comment.