diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..d7b194c --- /dev/null +++ b/.clang-format @@ -0,0 +1,5 @@ +--- +BasedOnStyle: Mozilla +IndentWidth: 4 +... +# vim: set filetype=yaml: diff --git a/.cmake-format.yaml b/.cmake-format.yaml new file mode 100644 index 0000000..60ae177 --- /dev/null +++ b/.cmake-format.yaml @@ -0,0 +1,4 @@ +format: + tab_size: 4 + use_tabchars: true + fractional_tab_policy: round-up diff --git a/.gitignore b/.gitignore index f0b69a4..3032325 100644 --- a/.gitignore +++ b/.gitignore @@ -66,3 +66,4 @@ tags *.exe *.out *.app +/version.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 0ae4414..b5766bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,2 +1,45 @@ # CMake configuration for demo project cmake_minimum_required(VERSION 3.16) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_CLANG_TIDY clang-tidy) +set(BOOST_ENABLE_CMAKE ON) + +execute_process( + COMMAND git describe --tags --dirty --always + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE VERSION_STRING + OUTPUT_STRIP_TRAILING_WHITESPACE) + +string(REGEX REPLACE "^v?([0-9]+)\\.([0-9]+)\\.([0-9]+).*$" "\\1.\\2.\\3" + MODIFIED_VERSION_STRING "${VERSION_STRING}") +project( + collector + VERSION ${MODIFIED_VERSION_STRING} + LANGUAGES CXX) + +include(FetchContent) +set(FETCHCONTENT_QUIET FALSE) + +FetchContent_Declare( + boostorg + GIT_REPOSITORY https://github.com/boostorg/boost.git + GIT_TAG boost-1.80.0 + GIT_PROGRESS TRUE + GIT_SHALLOW TRUE + FETCHCONTENT_QUIET FALSE) + +FetchContent_MakeAvailable(boostorg) + + +enable_testing() + +configure_file(version.hpp.in ${PROJECT_SOURCE_DIR}/version.hpp) + +add_executable(collector_test test.cpp) +target_compile_options(${PROJECT_NAME}_test PUBLIC -Wall -Wextra -Wshadow + -Wnon-virtual-dtor) +add_test(NAME test1 COMMAND collector_test) + +target_link_libraries(collector_test PRIVATE Boost::filesystem Boost::system + Boost::unit_test_framework) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1bd0b00 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2022 Tobias Schmidl + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/collector.hpp b/collector.hpp new file mode 100644 index 0000000..c7ffc2f --- /dev/null +++ b/collector.hpp @@ -0,0 +1,14 @@ +#pragma once +#include +namespace collector +{ + class Event + {}; + class Collector + { + private: + std::deque _event_queue; + public: + const auto get_length() const { return _event_queue.size(); } + }; +} diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..855370c --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +cmakelang[yaml]~=0.6.13 diff --git a/test.cpp b/test.cpp new file mode 100644 index 0000000..173af0f --- /dev/null +++ b/test.cpp @@ -0,0 +1,13 @@ +#include "collector.hpp" +#include "version.hpp" +#define BOOST_TEST_MODULE Collector test +#include + +using namespace collector; + +BOOST_AUTO_TEST_CASE(collector_test) +{ + BOOST_TEST_MESSAGE( "Test version " << VERSION ); + Collector foo; + BOOST_TEST(foo.get_length() == 0u); +} diff --git a/version.hpp.in b/version.hpp.in new file mode 100644 index 0000000..0c206a9 --- /dev/null +++ b/version.hpp.in @@ -0,0 +1,5 @@ +#define VERSION_MAJOR @PROJECT_VERSION_MAJOR@ +#define VERSION_MINOR @PROJECT_VERSION_MINOR@ +#define VERSION_PATCH @PROJECT_VERSION_PATCH@ +#define VERSION_TWEAK @PROJECT_VERSION_TWEAK@ +#define VERSION "@PROJECT_VERSION@"