From 6caf006214c60c4a770c4be42e59330d65c4321a Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Mon, 19 Sep 2022 12:35:03 +0300 Subject: [PATCH] Minor tweaks to boost library detection - Change default WITH_BOOST path to reside inside source tree to avoid permission problems or accidentally overwriting directories outside source tree. - If system Boost installation is not found, optionally use header only unit test framework from location specified by WITH_BOOST. - Fix extra-semi warning in provider_options.hpp. --- CMakeLists.txt | 29 ++++++++++++++++++++++++----- cmake/boost.cmake | 2 +- include/wsrep/provider_options.hpp | 2 +- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d928fa5..fad26cf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,14 +125,14 @@ if (WSREP_LIB_WITH_UNIT_TESTS) check_include_file_cxx(${json_HEADER} system_json_FOUND) if (NOT system_json_FOUND) if (NOT WITH_BOOST) - set(WITH_BOOST "${CMAKE_SOURCE_DIR}/../boost") + set(WITH_BOOST "${CMAKE_SOURCE_DIR}/third_party/boost") endif() set(DOWNLOAD_BOOST ON) include (cmake/boost.cmake) set(MIN_BOOST_VERSION "${BOOST_MAJOR}.${BOOST_MINOR}.${BOOST_PATCH}") message(STATUS "Boost includes: ${BOOST_INCLUDE_DIR}, ver: ${MIN_BOOST_VERSION}") find_package(Boost ${MIN_BOOST_VERSION} REQUIRED - COMPONENTS json headers + COMPONENTS json headers unit_test_framework PATHS ${WITH_BOOST}/lib/cmake NO_DEFAULT_PATH ) @@ -149,10 +149,29 @@ if (WSREP_LIB_WITH_UNIT_TESTS) include_directories(SYSTEM ${ADDITIONAL_CXX_INCLUDES}) endif() endif() + else() + find_package(Boost ${MIN_BOOST_VERSION} + COMPONENTS unit_test_framework + ) + + if (NOT Boost_UNIT_TEST_FRAMEWORK_FOUND) + # Check if we have header implementation available from + # extracted source tarball. + if (NOT WITH_BOOST) + message(FATAL_ERROR "System Boost not found, specify Boost installation with WITH_BOOST=") + endif() + CHECK_CXX_SOURCE_COMPILES( + " +#define BOOST_TEST_ALTERNATIVE_INIT_API +#include +bool init_unit_test() { return true; } +" + FOUND_BOOST_TEST_INCLUDED_UNIT_TEST_HPP) + if (NOT FOUND_BOOST_TEST_INCLUDED_UNIT_TEST_HPP) + message(FATAL_ERROR "Boost unit test header not found") + endif() + endif() endif() - find_package(Boost ${MIN_BOOST_VERSION} REQUIRED - unit_test_framework - ) endif() if (WSREP_LIB_WITH_DBSIM) diff --git a/cmake/boost.cmake b/cmake/boost.cmake index 8c48fda..982ebe6 100644 --- a/cmake/boost.cmake +++ b/cmake/boost.cmake @@ -48,7 +48,7 @@ FUNCTION(GET_FILE_SIZE FILE_NAME OUTPUT_SIZE) ENDFUNCTION() SET(BOOST_MAJOR "1") -SET(BOOST_MINOR "76") +SET(BOOST_MINOR "77") SET(BOOST_PATCH "0") SET(BOOST_PACKAGE_NAME "boost_${BOOST_MAJOR}_${BOOST_MINOR}_${BOOST_PATCH}") SET(BOOST_TARBALL "${BOOST_PACKAGE_NAME}.tar.gz") diff --git a/include/wsrep/provider_options.hpp b/include/wsrep/provider_options.hpp index 31877f5..21d227b 100644 --- a/include/wsrep/provider_options.hpp +++ b/include/wsrep/provider_options.hpp @@ -57,7 +57,7 @@ namespace wsrep class option_value { public: - virtual ~option_value(){}; + virtual ~option_value(){} virtual const char* as_string() const = 0; virtual const void* get_ptr() const = 0; };