diff options
author | tastytea | 2020-01-03 08:30:29 +0100 |
---|---|---|
committer | tastytea | 2020-01-03 08:32:03 +0100 |
commit | 5dc047811e29670f924f9123b6b96949b24e3363 (patch) | |
tree | 40b436de0e2b1dbc4d01948c3ceb314008ad4266 | |
parent | 4d7d360f9465ce88f31e3773cb6a4bfc5ed1fb18 (diff) | |
download | mastodonpp-5dc047811e29670f924f9123b6b96949b24e3363.tar mastodonpp-5dc047811e29670f924f9123b6b96949b24e3363.tar.gz mastodonpp-5dc047811e29670f924f9123b6b96949b24e3363.zip |
Add skeleton.
-rw-r--r-- | .editorconfig | 20 | ||||
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | CMakeLists.txt | 39 | ||||
-rw-r--r-- | cmake/debug_flags.cmake | 58 | ||||
-rw-r--r-- | include/mastodonpp.hpp | 39 | ||||
-rw-r--r-- | src/CMakeLists.txt | 27 | ||||
-rw-r--r-- | src/mastodonpp.cpp | 31 |
7 files changed, 216 insertions, 0 deletions
diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ad5e59f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# Configuration file for EditorConfig. +# More information is available under <https://editorconfig.org/>. + +root = true + +[*] +indent_style = space +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true +max_line_length = 80 + +[*.?pp] +indent_size = 4 +tab_width = 4 + +[{CMakeLists.txt,*.cmake}] +indent_size = 2 +tab_width = 2 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cace064 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/build/ +/doc/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7d56a9d --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,39 @@ +# Support version 3.9 and above, but use policy settings up to 3.14. +# 3.9 is needed for project description. +cmake_minimum_required(VERSION 3.9...3.14) +# Ranges are supported from 3.12, set policy to current for < 3.12. +if(${CMAKE_VERSION} VERSION_LESS 3.12) + cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) +endif() + +# Global build options. +set(CMAKE_BUILD_TYPE "Release" CACHE STRING "The type of build.") +option(BUILD_SHARED_LIBS "Build shared libraries." YES) + +project(mastodonpp + VERSION 0.0.0 + DESCRIPTION "C++ wrapper for the Mastodon API." + LANGUAGES CXX) + +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") + +# Project build options. +# option(WITH_TESTS "Compile tests." NO) +# option(WITH_DOC "Generate HTML documentation." YES) +# option(WITH_EXAMPLES "Compile examples." NO) +# option(WITH_DEB "Prepare for the building of .deb packages." NO) +# option(WITH_RPM "Prepare for the building of .rpm packages." NO) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) + +include(debug_flags) + +add_subdirectory(src) + +# if(WITH_TESTS) +# add_subdirectory(tests) +# endif() + +# include(cmake/packages.cmake) diff --git a/cmake/debug_flags.cmake b/cmake/debug_flags.cmake new file mode 100644 index 0000000..0009039 --- /dev/null +++ b/cmake/debug_flags.cmake @@ -0,0 +1,58 @@ +# Set compiler flags for Debug builds. +# Only has an effect on GCC/Clang >= 5.0. + +set(DEBUG_CXXFLAGS "") +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" + AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5") + list(APPEND DEBUG_CXXFLAGS + "-Wall" + "-Wextra" + "-Wpedantic" + "-Wuninitialized" + "-Wshadow" + "-Wnon-virtual-dtor" + "-Wconversion" + "-Wsign-conversion" + "-Wold-style-cast" + "-Wzero-as-null-pointer-constant" + "-Wmissing-declarations" + "-Wcast-align" + "-Wunused" + "-Woverloaded-virtual" + "-Wdouble-promotion" + "-Wformat=2" + "-ftrapv" + "-fsanitize=undefined" + "-g" + "-Og" + "-fno-omit-frame-pointer") + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + list(APPEND DEBUG_CXXFLAGS + "-Wlogical-op" + "-Wuseless-cast") + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6") + list(APPEND DEBUG_CXXFLAGS + "-Wmisleading-indentation" + "-Wduplicated-cond" + "-Wnull-dereference") + if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "7") + list(APPEND DEBUG_CXXFLAGS + "-Wduplicated-branches") + endif() + endif() + endif() + add_compile_options("$<$<CONFIG:Debug>:${DEBUG_CXXFLAGS}>") + + set(DEBUG_LDFLAGS + "-fsanitize=undefined") + # add_link_options was introduced in version 3.13. + if(${CMAKE_VERSION} VERSION_LESS 3.13) + set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${DEBUG_LDFLAGS}") + else() + add_link_options("$<$<CONFIG:Debug>:${DEBUG_LDFLAGS}>") + endif() +else() + message(STATUS + "No additional compiler flags were set, " + "because your compiler was not anticipated.") +endif() diff --git a/include/mastodonpp.hpp b/include/mastodonpp.hpp new file mode 100644 index 0000000..713712d --- /dev/null +++ b/include/mastodonpp.hpp @@ -0,0 +1,39 @@ +/* This file is part of mastodonpp. + * Copyright © 2020 tastytea <tastytea@tastytea.de> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, version 3. + * + * 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef MASTODONPP_HPP +#define MASTODONPP_HPP + +#include <string> + +namespace mastodonpp +{ + +using std::string; + +class API +{ +public: + explicit API(string instance, string access_token); + +private: + const string _instance; + const string _access_token; +}; + +} // namespace mastodonpp + +#endif // MASTODONPP_HPP diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..e5c64f6 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,27 @@ +include(GNUInstallDirs) + +file(GLOB_RECURSE sources_lib *.cpp) +file(GLOB_RECURSE headers_lib ../include/*.hpp) + +add_library(${PROJECT_NAME} "${sources_lib}" "${headers_lib}") + +set_target_properties(${PROJECT_NAME} PROPERTIES + VERSION ${PROJECT_VERSION} + SOVERSION ${${PROJECT_NAME}_VERSION_MAJOR}) + +target_include_directories(${PROJECT_NAME} + PRIVATE + "$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src>" # version.hpp + PUBLIC + "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>" + "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>") + +# target_link_libraries(${PROJECT_NAME} +# PRIVATE +# PUBLIC) + + +install(TARGETS ${PROJECT_NAME} + EXPORT "${PROJECT_NAME}Targets" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}") diff --git a/src/mastodonpp.cpp b/src/mastodonpp.cpp new file mode 100644 index 0000000..7890ed6 --- /dev/null +++ b/src/mastodonpp.cpp @@ -0,0 +1,31 @@ +/* This file is part of mastodonpp. + * Copyright © 2020 tastytea <tastytea@tastytea.de> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, version 3. + * + * 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "mastodonpp.hpp" + +#include <utility> + +namespace mastodonpp +{ + +using std::move; + +API::API(string instance, string access_token) + : _instance{move(instance)} + , _access_token{move(access_token)} +{} + +} // namespace mastodonpp |