Skip to content

Commit

Permalink
Merge pull request #172 from boostorg/cmake-build-in-tree
Browse files Browse the repository at this point in the history
In-tree cmake builds instead of FindBoost.
  • Loading branch information
mzimbres authored Dec 30, 2023
2 parents 2685d44 + be1a1fb commit 7c788af
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 8 deletions.
69 changes: 66 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion example/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -46,4 +49,4 @@ endif()

if (NOT MSVC)
make_example(cpp20_chat_room 20)
endif()
endif()
4 changes: 1 addition & 3 deletions example/cpp20_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@

#if defined(BOOST_ASIO_HAS_CO_AWAIT)

#define BOOST_JSON_NO_LIB
#define BOOST_CONTAINER_NO_LIB
#include <boost/json/serialize.hpp>
#include <boost/json/parse.hpp>
#include <boost/json/value_from.hpp>
#include <boost/json/value_to.hpp>
#include <boost/redis/resp3/serialization.hpp>
#include <boost/json/src.hpp>

namespace asio = boost::asio;
using namespace boost::describe;
Expand Down
3 changes: 2 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -70,4 +71,4 @@ add_custom_target(
COMMAND ${COVERAGE_HTML_COMMAND}
COMMENT "Generating coverage report"
VERBATIM
)
)

0 comments on commit 7c788af

Please sign in to comment.