Add skeleton.
This commit is contained in:
parent
4d7d360f94
commit
5dc047811e
20
.editorconfig
Normal file
20
.editorconfig
Normal file
|
@ -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
|
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
/build/
|
||||
/doc/
|
39
CMakeLists.txt
Normal file
39
CMakeLists.txt
Normal file
|
@ -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)
|
58
cmake/debug_flags.cmake
Normal file
58
cmake/debug_flags.cmake
Normal file
|
@ -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()
|
39
include/mastodonpp.hpp
Normal file
39
include/mastodonpp.hpp
Normal file
|
@ -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
|
27
src/CMakeLists.txt
Normal file
27
src/CMakeLists.txt
Normal file
|
@ -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}")
|
31
src/mastodonpp.cpp
Normal file
31
src/mastodonpp.cpp
Normal file
|
@ -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
|
Loading…
Reference in New Issue
Block a user