diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..112fa99 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,53 @@ +# Copyright (C) 2024 by Skyward +# +# This program is free software; you can redistribute it and/or +# it under the terms of the GNU General Public License as published +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# As a special exception, if other files instantiate templates or use +# macros or inline functions from this file, or you compile this file +# and link it with other works to produce a work based on this file, +# this file does not by itself cause the resulting work to be covered +# by the GNU General Public License. However the source code for this +# file must still be made available in accordance with the GNU +# Public License. This exception does not invalidate any other +# why a work based on this file might be covered by the GNU General +# Public License. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see + +cmake_minimum_required(VERSION 3.16) + +project(TsCpp + DESCRIPTION "Trivial serialization for C++" + LANGUAGES CXX +) + +add_library(tscpp INTERFACE) +target_sources(tscpp INTERFACE src/tscpp/buffer.cpp src/tscpp/stream.cpp) +target_include_directories(tscpp INTERFACE include) + +add_executable(1_stream_known EXCLUDE_FROM_ALL examples/1_stream_known.cpp) +target_link_libraries(1_stream_known tscpp) + +add_executable(2_stream_unknown EXCLUDE_FROM_ALL examples/2_stream_unknown.cpp) +target_link_libraries(2_stream_unknown tscpp) + +add_executable(3_buffer_known EXCLUDE_FROM_ALL examples/3_buffer_known.cpp) +target_link_libraries(3_buffer_known tscpp) + +add_executable(4_buffer_unknown EXCLUDE_FROM_ALL examples/4_buffer_unknown.cpp) +target_link_libraries(4_buffer_unknown tscpp) + +add_executable(5_stream_failtest EXCLUDE_FROM_ALL examples/5_stream_failtest.cpp) +target_link_libraries(5_stream_failtest tscpp) + +add_executable(6_buffer_failtest EXCLUDE_FROM_ALL examples/6_buffer_failtest.cpp) +target_link_libraries(6_buffer_failtest tscpp) diff --git a/examples/Makefile b/examples/Makefile deleted file mode 100644 index 9134e38..0000000 --- a/examples/Makefile +++ /dev/null @@ -1,21 +0,0 @@ - -CXX = g++ -CXXFLAGS = -std=c++11 -g -O0 -fsanitize=address -Wall -I../.. - -all: - $(CXX) $(CXXFLAGS) 1_stream_known.cpp ../stream.cpp -o 1_stream_known - $(CXX) $(CXXFLAGS) 2_stream_unknown.cpp ../stream.cpp -o 2_stream_unknown - $(CXX) $(CXXFLAGS) 3_buffer_known.cpp ../buffer.cpp -o 3_buffer_known - $(CXX) $(CXXFLAGS) 4_buffer_unknown.cpp ../buffer.cpp -o 4_buffer_unknown - $(CXX) $(CXXFLAGS) 5_stream_failtest.cpp ../stream.cpp -o 5_stream_failtest - $(CXX) $(CXXFLAGS) 6_buffer_failtest.cpp ../buffer.cpp -o 6_buffer_failtest - ./1_stream_known - ./2_stream_unknown - ./3_buffer_known - ./4_buffer_unknown - ./5_stream_failtest - ./6_buffer_failtest - -clean: - rm -f 1_stream_known 2_stream_unknown 3_buffer_known 4_buffer_unknown \ - 5_stream_failtest 6_buffer_failtest diff --git a/buffer.h b/include/tscpp/buffer.h similarity index 100% rename from buffer.h rename to include/tscpp/buffer.h diff --git a/stream.h b/include/tscpp/stream.h similarity index 100% rename from stream.h rename to include/tscpp/stream.h diff --git a/buffer.cpp b/src/tscpp/buffer.cpp similarity index 99% rename from buffer.cpp rename to src/tscpp/buffer.cpp index 2b48417..07f24c9 100644 --- a/buffer.cpp +++ b/src/tscpp/buffer.cpp @@ -25,7 +25,7 @@ * along with this program; if not, see * ***************************************************************************/ -#include "buffer.h" +#include using namespace std; diff --git a/stream.cpp b/src/tscpp/stream.cpp similarity index 99% rename from stream.cpp rename to src/tscpp/stream.cpp index f9df3f4..6f1c33c 100644 --- a/stream.cpp +++ b/src/tscpp/stream.cpp @@ -25,7 +25,7 @@ * along with this program; if not, see * ***************************************************************************/ -#include "stream.h" +#include #include #if defined(__GNUC__) && !defined(_MIOSIX) #include