diff --git a/.gitignore b/.gitignore index 9e46be3..cba530b 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ compile_commands.json CTestTestfile.cmake _deps CMakeUserPresets.json +build/ # ---> Emacs # -*- mode: gitignore; -*- @@ -97,3 +98,4 @@ flycheck_*.el *.out *.app +.cache \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..4179071 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,25 @@ +cmake_minimum_required(VERSION 4.3.4) +project(Sabalty) + +set(CMAKE_CXX_STANDARD 23) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +option(BUILD_TESTING "Build tests" OFF) +if(BUILD_TESTING) + enable_testing() + + include(FetchContent) + FetchContent_Declare( + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v3.15.3 + ) + FetchContent_MakeAvailable(Catch2) + + include(CTest) + include(Catch) +endif() + +add_subdirectory(Server) +add_subdirectory(Protocol) diff --git a/Protocol/CMakeLists.txt b/Protocol/CMakeLists.txt new file mode 100644 index 0000000..fdfb8f4 --- /dev/null +++ b/Protocol/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(src) +add_subdirectory(tests) diff --git a/Protocol/src/CMakeLists.txt b/Protocol/src/CMakeLists.txt new file mode 100644 index 0000000..a7907c3 --- /dev/null +++ b/Protocol/src/CMakeLists.txt @@ -0,0 +1,10 @@ +add_library(Protocol STATIC) + +target_sources(Protocol + PRIVATE + protocol.cxx + PUBLIC + FILE_SET HEADERS + BASE_DIRS include + FILES include/protocol/protocol.hxx +) diff --git a/Protocol/src/include/protocol/protocol.hxx b/Protocol/src/include/protocol/protocol.hxx new file mode 100644 index 0000000..e69de29 diff --git a/Protocol/src/protocol.cxx b/Protocol/src/protocol.cxx new file mode 100644 index 0000000..e69de29 diff --git a/Protocol/tests/CMakeLists.txt b/Protocol/tests/CMakeLists.txt new file mode 100644 index 0000000..9a00cd7 --- /dev/null +++ b/Protocol/tests/CMakeLists.txt @@ -0,0 +1,11 @@ +add_executable(Protocol_tests + test_protocol.cxx +) + +target_link_libraries(Protocol_tests + PRIVATE + Protocol + Catch2::Catch2WithMain +) + +catch_discover_tests(Protocol_tests) diff --git a/Protocol/tests/test_protocol.cxx b/Protocol/tests/test_protocol.cxx new file mode 100644 index 0000000..58a94be --- /dev/null +++ b/Protocol/tests/test_protocol.cxx @@ -0,0 +1,6 @@ +#include +#include + +TEST_CASE("something", "[stun]") { + SECTION("true") { REQUIRE(true); } +} diff --git a/Server/CMakeLists.txt b/Server/CMakeLists.txt new file mode 100644 index 0000000..a422948 --- /dev/null +++ b/Server/CMakeLists.txt @@ -0,0 +1 @@ +add_subdirectory(Stun) diff --git a/Server/Stun/CMakeLists.txt b/Server/Stun/CMakeLists.txt new file mode 100644 index 0000000..fdfb8f4 --- /dev/null +++ b/Server/Stun/CMakeLists.txt @@ -0,0 +1,2 @@ +add_subdirectory(src) +add_subdirectory(tests) diff --git a/Server/Stun/src/CMakeLists.txt b/Server/Stun/src/CMakeLists.txt new file mode 100644 index 0000000..d1638ad --- /dev/null +++ b/Server/Stun/src/CMakeLists.txt @@ -0,0 +1,10 @@ +add_library(Stun STATIC) + +target_sources(Stun + PRIVATE + stun.cxx + PUBLIC + FILE_SET HEADERS + BASE_DIRS include + FILES include/stun/stun.hxx +) diff --git a/Server/Stun/src/include/stun/stun.hxx b/Server/Stun/src/include/stun/stun.hxx new file mode 100644 index 0000000..9ad94a4 --- /dev/null +++ b/Server/Stun/src/include/stun/stun.hxx @@ -0,0 +1,7 @@ +#pragma once + +namespace stun { + +int add_numbers(int, int); + +} diff --git a/Server/Stun/src/stun.cxx b/Server/Stun/src/stun.cxx new file mode 100644 index 0000000..d8c1457 --- /dev/null +++ b/Server/Stun/src/stun.cxx @@ -0,0 +1,3 @@ +#include + +int stun::add_numbers(int x, int y) { return (x + y); } diff --git a/Server/Stun/tests/CMakeLists.txt b/Server/Stun/tests/CMakeLists.txt new file mode 100644 index 0000000..3a05f63 --- /dev/null +++ b/Server/Stun/tests/CMakeLists.txt @@ -0,0 +1,11 @@ +add_executable(Stun_tests + test_stun.cxx +) + +target_link_libraries(Stun_tests + PRIVATE + Stun + Catch2::Catch2WithMain +) + +catch_discover_tests(Stun_tests) diff --git a/Server/Stun/tests/test_stun.cxx b/Server/Stun/tests/test_stun.cxx new file mode 100644 index 0000000..b63a681 --- /dev/null +++ b/Server/Stun/tests/test_stun.cxx @@ -0,0 +1,6 @@ +#include +#include + +TEST_CASE("add_numbers works", "[stun]") { + SECTION("adding 1 to 2") { REQUIRE(stun::add_numbers(1, 2) == 3); } +}