From 4257b2eaec0fa75000ad727ac463161114e9a6c3 Mon Sep 17 00:00:00 2001 From: Marcelo Zimbres Date: Thu, 28 Dec 2023 23:09:39 +0100 Subject: [PATCH] In-tree cmake builds instead of FindBoost. --- CMakeLists.txt | 69 ++++++++++++++++++++++++++++++++++++++++-- example/CMakeLists.txt | 5 ++- example/cpp20_json.cpp | 4 +-- test/CMakeLists.txt | 3 +- 4 files changed, 73 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f442d55c..60d07175 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,13 +19,76 @@ target_compile_features(boost_redis INTERFACE cxx_std_17) # Dependencies if (BOOST_REDIS_MAIN_PROJECT) - # If we're the root project, error if a dependency is not found - find_package(Boost 1.83 REQUIRED COMPONENTS headers) + # TODO: Understand why we have to list all dependencies below + # instead of + #set(BOOST_INCLUDE_LIBRARIES redis) + #set(BOOST_EXCLUDE_LIBRARIES redis) + #add_subdirectory(../.. boostorg/boost EXCLUDE_FROM_ALL) + + set(deps + system + assert + config + throw_exception + asio + variant2 + mp11 + winapi + predef + align + context + core + coroutine + static_assert + pool + date_time + smart_ptr + exception + integer + move + type_traits + algorithm + utility + io + lexical_cast + numeric/conversion + mpl + range + tokenizer + tuple + array + bind + concept_check + function + iterator + regex + unordered + preprocessor + container + conversion + container_hash + detail + optional + function_types + fusion + intrusive + describe + typeof + functional + test + json + ) + + foreach(dep IN LISTS deps) + add_subdirectory(../${dep} boostorg/${dep}) + endforeach() + find_package(Threads REQUIRED) find_package(OpenSSL REQUIRED) target_link_libraries(boost_redis INTERFACE - Boost::headers + Boost::system + Boost::asio Threads::Threads OpenSSL::Crypto OpenSSL::SSL diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 16531341..a727b75b 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -10,6 +10,9 @@ macro(make_example EXAMPLE_NAME STANDARD) if (${STANDARD} STREQUAL "20") target_link_libraries(${EXAMPLE_NAME} PRIVATE examples_main) endif() + if (${STANDARD} STREQUAL "20") + target_link_libraries(${EXAMPLE_NAME} PRIVATE Boost::json) + endif() endmacro() macro(make_testable_example EXAMPLE_NAME STANDARD) @@ -46,4 +49,4 @@ endif() if (NOT MSVC) make_example(cpp20_chat_room 20) -endif() \ No newline at end of file +endif() diff --git a/example/cpp20_json.cpp b/example/cpp20_json.cpp index 2f0674f0..261a3f2f 100644 --- a/example/cpp20_json.cpp +++ b/example/cpp20_json.cpp @@ -15,13 +15,11 @@ #if defined(BOOST_ASIO_HAS_CO_AWAIT) -#define BOOST_JSON_NO_LIB -#define BOOST_CONTAINER_NO_LIB #include #include #include +#include #include -#include namespace asio = boost::asio; using namespace boost::describe; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6d615c5b..40edb275 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -23,6 +23,7 @@ macro(make_test TEST_NAME STANDARD) boost_redis_src boost_redis_tests_common boost_redis_project_options + Boost::unit_test_framework ) target_compile_features(${EXE_NAME} PRIVATE cxx_std_${STANDARD}) add_test(${EXE_NAME} ${EXE_NAME}) @@ -70,4 +71,4 @@ add_custom_target( COMMAND ${COVERAGE_HTML_COMMAND} COMMENT "Generating coverage report" VERBATIM -) \ No newline at end of file +)