82 lines
1.3 KiB
CMake
82 lines
1.3 KiB
CMake
cmake_minimum_required(VERSION 3.16)
|
|
|
|
|
|
#
|
|
#
|
|
# Global settings
|
|
#
|
|
#
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
project(playground)
|
|
|
|
|
|
#
|
|
#
|
|
# Dependencies
|
|
#
|
|
#
|
|
|
|
# spdlog
|
|
|
|
find_package(spdlog REQUIRED)
|
|
|
|
# Google Test
|
|
|
|
include(FetchContent)
|
|
FetchContent_Declare(
|
|
googletest
|
|
URL https://github.com/google/googletest/archive/03597a01ee50ed33e9dfd640b249b4be3799d395.zip
|
|
)
|
|
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
|
FetchContent_MakeAvailable(googletest)
|
|
|
|
|
|
#
|
|
#
|
|
# Executabless
|
|
#
|
|
#
|
|
|
|
|
|
add_executable(playground src/main.cpp src/tcp_server.cpp src/tcp_client.cpp)
|
|
target_link_libraries(playground PRIVATE spdlog::spdlog)
|
|
|
|
|
|
#
|
|
#
|
|
# Tests
|
|
#
|
|
#
|
|
|
|
|
|
include(GoogleTest)
|
|
|
|
|
|
enable_testing()
|
|
|
|
add_executable(tcp_blocking_test
|
|
tests/tcp_blocking.cpp
|
|
src/tcp_server.cpp
|
|
src/tcp_client.cpp
|
|
)
|
|
target_link_libraries(tcp_blocking_test spdlog::spdlog GTest::gtest_main)
|
|
target_include_directories(tcp_blocking_test PRIVATE src)
|
|
|
|
gtest_discover_tests(tcp_blocking_test)
|
|
|
|
add_executable(tcp_non_blocking_test
|
|
tests/tcp_non_blocking.cpp
|
|
src/tcp_server.cpp
|
|
src/tcp_client.cpp
|
|
)
|
|
target_link_libraries(tcp_non_blocking_test spdlog::spdlog GTest::gtest_main)
|
|
target_include_directories(tcp_non_blocking_test PRIVATE src)
|
|
|
|
gtest_discover_tests(tcp_non_blocking_test)
|
|
|