Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
402 changes: 307 additions & 95 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

171 changes: 45 additions & 126 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
cmake_minimum_required(VERSION 3.8...3.20)

# determine whether it's main/root project
# or being built under another project.
if (NOT DEFINED BOOST_REDIS_MAIN_PROJECT)
set(BOOST_REDIS_MAIN_PROJECT OFF)
if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
set(BOOST_REDIS_MAIN_PROJECT ON)
endif()
endif()
cmake_minimum_required(VERSION 3.8...4.2)

project(boost_redis VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)

Expand All @@ -18,125 +9,53 @@ target_include_directories(boost_redis INTERFACE include)
target_compile_features(boost_redis INTERFACE cxx_std_17)

# Dependencies
if (BOOST_REDIS_MAIN_PROJECT)
# 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
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
endian
compat
)

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::system
Boost::asio
Threads::Threads
OpenSSL::Crypto
OpenSSL::SSL
)
else()
# If we're in the superproject or called from add_subdirectory,
# Boost dependencies should be already available.
# If other dependencies are not found, we bail out
find_package(Threads)
if(NOT Threads_FOUND)
message(STATUS "Boost.Redis has been disabled, because the required package Threads hasn't been found")
return()
endif()
find_package(OpenSSL)
if(NOT OpenSSL_FOUND)
message(STATUS "Boost.Redis has been disabled, because the required package OpenSSL hasn't been found")
return()
endif()

# This is generated by boostdep
target_link_libraries(boost_redis
INTERFACE
Boost::asio
Boost::assert
Boost::core
Boost::mp11
Boost::system
Boost::throw_exception
Threads::Threads
OpenSSL::Crypto
OpenSSL::SSL
)
# Boost dependencies should be already available.
# If other dependencies are not found, we bail out
find_package(Threads)
if(NOT Threads_FOUND)
message(STATUS "Boost.Redis has been disabled, because the required package Threads hasn't been found")
return()
endif()

# Enable testing. If we're being called from the superproject, this has already been done
if (BOOST_REDIS_MAIN_PROJECT)
include(CTest)
find_package(OpenSSL)
if(NOT OpenSSL_FOUND)
message(STATUS "Boost.Redis has been disabled, because the required package OpenSSL hasn't been found")
return()
endif()

# Most tests require a running Redis server, so we only run them if we're the main project
if(BOOST_REDIS_MAIN_PROJECT AND BUILD_TESTING)
# This is generated by boostdep
target_link_libraries(boost_redis
INTERFACE
Boost::asio
Boost::assert
Boost::core
Boost::mp11
Boost::system
Boost::throw_exception
Threads::Threads
OpenSSL::Crypto
OpenSSL::SSL
)

# Don't run integration testing unless explicitly requested, since these require a running server
option(BOOST_REDIS_INTEGRATION_TESTS OFF "Whether to build and run integration tests or not")
mark_as_advanced(BOOST_REDIS_INTEGRATION_TESTS)

# Examples and tests
if(BUILD_TESTING)
# Custom target tests; required by the Boost superproject
if(NOT TARGET tests)
add_custom_target(tests)
endif()

# Tests and common utilities
add_subdirectory(test)

# Benchmarks. Build them with tests to prevent code rotting
add_subdirectory(benchmarks)

# Examples
add_subdirectory(example)

if (BOOST_REDIS_INTEGRATION_TESTS)
# Benchmarks. Build them with tests to prevent code rotting.
# Guarded to prevent them from building in normal builds
add_subdirectory(benchmarks)

# Examples. All of them require a real server running
add_subdirectory(example)
endif()
endif()
25 changes: 8 additions & 17 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@

add_library(benchmarks_options INTERFACE)
target_link_libraries(benchmarks_options INTERFACE boost_redis_src)
target_link_libraries(benchmarks_options INTERFACE boost_redis_project_options)
target_compile_features(benchmarks_options INTERFACE cxx_std_20)
add_library(boost_redis_benchmarks_options INTERFACE)
target_link_libraries(boost_redis_benchmarks_options INTERFACE boost_redis_src)
target_link_libraries(boost_redis_benchmarks_options INTERFACE boost_redis_project_options)
target_compile_features(boost_redis_benchmarks_options INTERFACE cxx_std_20)

add_executable(echo_server_client cpp/asio/echo_server_client.cpp)
target_link_libraries(echo_server_client PRIVATE benchmarks_options)
add_executable(boost_redis_echo_server_client cpp/asio/echo_server_client.cpp)
target_link_libraries(boost_redis_echo_server_client PRIVATE boost_redis_benchmarks_options)

add_executable(echo_server_direct cpp/asio/echo_server_direct.cpp)
target_link_libraries(echo_server_direct PRIVATE benchmarks_options)

# TODO
#=======================================================================

#.PHONY: bench
#bench:
# pdflatex --jobname=echo-f0 benchmarks/benchmarks.tex
# pdflatex --jobname=echo-f1 benchmarks/benchmarks.tex
# pdftoppm {input.pdf} {output.file} -png
add_executable(boost_redis_echo_server_direct cpp/asio/echo_server_direct.cpp)
target_link_libraries(boost_redis_echo_server_direct PRIVATE boost_redis_benchmarks_options)
Loading
Loading