mirror of
https://github.com/boostorg/redis.git
synced 2026-01-19 04:42:09 +00:00
49 lines
1.7 KiB
CMake
49 lines
1.7 KiB
CMake
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()
|
|
endmacro()
|
|
|
|
macro(make_testable_example EXAMPLE_NAME STANDARD)
|
|
make_example(${EXAMPLE_NAME} ${STANDARD})
|
|
if (BOOST_REDIS_INTEGRATION_TESTS)
|
|
add_test(${EXAMPLE_NAME} ${EXAMPLE_NAME})
|
|
endif()
|
|
endmacro()
|
|
|
|
make_testable_example(cpp17_intro 17)
|
|
make_testable_example(cpp17_intro_sync 17)
|
|
|
|
make_testable_example(cpp20_intro 20)
|
|
make_testable_example(cpp20_containers 20)
|
|
make_testable_example(cpp20_json 20)
|
|
make_testable_example(cpp20_intro_tls 20)
|
|
|
|
make_example(cpp20_subscriber 20)
|
|
make_example(cpp20_streams 20)
|
|
make_example(cpp20_echo_server 20)
|
|
make_example(cpp20_resolve_with_sentinel 20)
|
|
|
|
# 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)
|
|
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)
|
|
endif() |