From 71cece60da7e4fc9dbb6b942a7f637d4aae91b1e Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Sun, 29 Mar 2026 12:20:29 +0200 Subject: [PATCH 1/2] Examples no longer force std level --- example/CMakeLists.txt | 2 -- 1 file changed, 2 deletions(-) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 7f77b4f10..3f0c1ed4f 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,12 +1,10 @@ add_library(examples_main STATIC main.cpp) -target_compile_features(examples_main PRIVATE cxx_std_20) target_link_libraries(examples_main PRIVATE boost_redis_project_options) macro(make_example EXAMPLE_NAME STANDARD) add_executable(${EXAMPLE_NAME} ${EXAMPLE_NAME}.cpp) target_link_libraries(${EXAMPLE_NAME} PRIVATE boost_redis_src) target_link_libraries(${EXAMPLE_NAME} PRIVATE boost_redis_project_options) - target_compile_features(${EXAMPLE_NAME} PRIVATE cxx_std_${STANDARD}) if (${STANDARD} STREQUAL "20") target_link_libraries(${EXAMPLE_NAME} PRIVATE examples_main) endif() From 053af9dd35d538654b45deb7f01dfebc874b8b1d Mon Sep 17 00:00:00 2001 From: Ruben Perez Date: Sun, 29 Mar 2026 12:44:14 +0200 Subject: [PATCH 2/2] Refactors the example CMake --- example/CMakeLists.txt | 49 +++++++++++++++++++----------------------- test/CMakeLists.txt | 2 -- 2 files changed, 22 insertions(+), 29 deletions(-) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 3f0c1ed4f..55fde8579 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,59 +1,54 @@ add_library(examples_main STATIC main.cpp) target_link_libraries(examples_main PRIVATE boost_redis_project_options) -macro(make_example EXAMPLE_NAME STANDARD) +function(make_example EXAMPLE_NAME) add_executable(${EXAMPLE_NAME} ${EXAMPLE_NAME}.cpp) target_link_libraries(${EXAMPLE_NAME} PRIVATE boost_redis_src) target_link_libraries(${EXAMPLE_NAME} PRIVATE boost_redis_project_options) - if (${STANDARD} STREQUAL "20") - target_link_libraries(${EXAMPLE_NAME} PRIVATE examples_main) + if (ARGN) + target_link_libraries(${EXAMPLE_NAME} PRIVATE ${ARGN}) endif() - if (${EXAMPLE_NAME} STREQUAL "cpp20_json") - target_link_libraries(${EXAMPLE_NAME} PRIVATE Boost::json Boost::container_hash) - endif() -endmacro() +endfunction() -macro(make_testable_example EXAMPLE_NAME STANDARD) - make_example(${EXAMPLE_NAME} ${STANDARD}) +function(make_testable_example EXAMPLE_NAME) + make_example(${EXAMPLE_NAME} ${ARGN}) add_test(${EXAMPLE_NAME} ${EXAMPLE_NAME} $ENV{BOOST_REDIS_TEST_SERVER} 6379) -endmacro() +endfunction() -make_testable_example(cpp17_intro 17) -make_testable_example(cpp17_intro_sync 17) +make_testable_example(cpp17_intro) +make_testable_example(cpp17_intro_sync) -make_testable_example(cpp20_intro 20) -make_testable_example(cpp20_containers 20) -make_testable_example(cpp20_json 20) -make_testable_example(cpp20_unix_sockets 20) -make_testable_example(cpp20_timeouts 20) -make_testable_example(cpp20_sentinel 20) +make_testable_example(cpp20_intro examples_main) +make_testable_example(cpp20_containers examples_main) +make_testable_example(cpp20_json examples_main Boost::json Boost::container_hash) +make_testable_example(cpp20_unix_sockets examples_main) +make_testable_example(cpp20_timeouts examples_main) +make_testable_example(cpp20_sentinel examples_main) -make_example(cpp20_subscriber 20) -make_example(cpp20_streams 20) -make_example(cpp20_echo_server 20) -make_example(cpp20_intro_tls 20) +make_example(cpp20_subscriber examples_main) +make_example(cpp20_streams examples_main) +make_example(cpp20_echo_server examples_main) +make_example(cpp20_intro_tls examples_main) # We test the protobuf example only on gcc. if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") find_package(Protobuf) if (Protobuf_FOUND) protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS person.proto) - make_testable_example(cpp20_protobuf 20) + make_testable_example(cpp20_protobuf examples_main ${Protobuf_LIBRARIES}) target_sources(cpp20_protobuf PUBLIC ${PROTO_SRCS} ${PROTO_HDRS}) - target_link_libraries(cpp20_protobuf PRIVATE ${Protobuf_LIBRARIES}) target_include_directories(cpp20_protobuf PUBLIC ${Protobuf_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) endif() endif() if (NOT MSVC) - make_example(cpp20_chat_room 20) + make_example(cpp20_chat_room examples_main) endif() # We build and test the spdlog integration example only if the library is found find_package(spdlog) if (spdlog_FOUND) - make_testable_example(cpp17_spdlog 17) - target_link_libraries(cpp17_spdlog PRIVATE spdlog::spdlog) + make_testable_example(cpp17_spdlog spdlog::spdlog) else() message(STATUS "Skipping the spdlog example because the spdlog package couldn't be found") endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4eb460add..aabf8b7b2 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -11,12 +11,10 @@ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL endif() add_library(boost_redis_src STATIC boost_redis.cpp) -target_compile_features(boost_redis_src PRIVATE cxx_std_17) target_link_libraries(boost_redis_src PRIVATE boost_redis_project_options) # Test utils add_library(boost_redis_tests_common STATIC common.cpp sansio_utils.cpp) -target_compile_features(boost_redis_tests_common PRIVATE cxx_std_17) target_link_libraries(boost_redis_tests_common PRIVATE boost_redis_project_options) macro(make_test TEST_NAME)