diff --git a/CMakeLists.txt b/CMakeLists.txt index 33b95ca..313eef0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.14) -project(mastodont-c - VERSION 0.0 - DESCRIPTION "Terrible library for Mastodon and Pleroma 'n Friends" +project(mastodont + VERSION 0.1 + DESCRIPTION "Library for Mastodon, Pleroma, Wormhole, etc." LANGUAGES C) # Useful @@ -9,9 +9,44 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_package(PkgConfig REQUIRED) find_package(CURL REQUIRED) -add_library(mastodont-c STATIC) +add_library(mastodont STATIC) -target_sources(mastodont-c PUBLIC +set(HEADERS_FILES + include/mastodont_account.h + include/mastodont_announcement.h + include/mastodont_application.h + include/mastodont_attachment.h + include/mastodont_chats.h + include/mastodont_codes.h + include/mastodont_emoji.h + include/mastodont_error.h + include/mastodont_fetch.h + include/mastodont_generate.h + include/mastodont_history.h + include/mastodont_hooks.h + include/mastodont_instance.h + include/mastodont_json_helper.h + include/mastodont_list.h + include/mastodont_mention.h + include/mastodont_nodeinfo.h + include/mastodont_notif_types.h + include/mastodont_notification.h + include/mastodont_pleroma.h + include/mastodont_query.h + include/mastodont_relationship.h + include/mastodont_request.h + include/mastodont_scrobbles.h + include/mastodont_search.h + include/mastodont_status.h + include/mastodont_tag.h + include/mastodont_timeline.h + include/mastodont_types.h + include/mastodont_uri.h + include/mastodont_visibility_types.h + include/mastodont.h +) + +target_sources(mastodont PUBLIC src/account.c src/application.c src/attachment.c @@ -42,17 +77,17 @@ target_sources(mastodont-c PUBLIC libs/cjson/cJSON.c ) -target_compile_options(mastodont-c PUBLIC +target_compile_options(mastodont PUBLIC -Wall -Wextra -std=c99 -Wshadow -Wcast-align -Wstrict-prototypes ) -target_link_options(mastodont-c PUBLIC +target_link_options(mastodont PUBLIC -lmastodont ${CURL_LDFLAGS_OTHER} ) -target_include_directories(mastodont-c PUBLIC +target_include_directories(mastodont PUBLIC include/ ${CURL_INCLUDE_DIRS} @@ -60,3 +95,8 @@ target_include_directories(mastodont-c PUBLIC libs/ ) +install(FILES ${HEADER_FILES} DESTINATION include/mastodont/) +install(TARGETS mastodont LIBRARY DESTINATION lib) +# TODO +#install(FILES MastodontConfig.cmake DESTINATION lib/cmake/mastodont) + diff --git a/cmake/FindMastodont.cmake b/cmake/FindMastodont.cmake deleted file mode 100644 index 7e9b996..0000000 --- a/cmake/FindMastodont.cmake +++ /dev/null @@ -1,18 +0,0 @@ -#[=======================================================================[.rst: -FindMastodont --------- - -Find the Mastodont library. - -Result Variables -^^^^^^^^^^^^^^^^ - -This module defines the following variables: - -``CURL_FOUND`` -``CURL_INCLUDE_DIRS`` -``CURL_LIBRARIES`` -``CURL_VERSION_STRING`` - -#]=======================================================================] - diff --git a/include/mastodont.h b/include/mastodont.h index d60eec6..dc6efba 100644 --- a/include/mastodont.h +++ b/include/mastodont.h @@ -19,9 +19,11 @@ #include /// Initializes libcurl -void mstdnt_global_curl_init(); +void +mstdnt_global_curl_init(void); /// Cleans up libcurl -void mstdnt_global_curl_cleanup(); +void +mstdnt_global_curl_cleanup(void); /** * Initializes a mstdnt struct @@ -29,14 +31,16 @@ void mstdnt_global_curl_cleanup(); * @param data Pointer to struct to fill in * @return Value of curl_easy_init(); either Zero or non-zero */ -int mstdnt_init(mastodont_t* data); +int +mstdnt_init(mastodont_t* data); /** * Cleans up the mstdnt struct * * @param data Pointer to the mstdnt data */ -void mstdnt_cleanup(mastodont_t* data); +void +mstdnt_cleanup(mastodont_t* data); /** * Cleans up a storage struct. @@ -45,6 +49,7 @@ void mstdnt_cleanup(mastodont_t* data); * * @param storage The storage block to cleanup */ -void mstdnt_storage_cleanup(struct mstdnt_storage* storage); +void +mstdnt_storage_cleanup(struct mstdnt_storage *storage); #endif /* MASTODONT_H */ diff --git a/include/mastodont_scrobbles.h b/include/mastodont_scrobbles.h index 01165c6..bd10c6b 100644 --- a/include/mastodont_scrobbles.h +++ b/include/mastodont_scrobbles.h @@ -5,7 +5,6 @@ #ifndef MASTODONT_SCROBBLES_H #define MASTODONT_SCROBBLES_H #include -#include #include #include diff --git a/include/mastodont_search.h b/include/mastodont_search.h index f0fd623..1ea8ab0 100644 --- a/include/mastodont_search.h +++ b/include/mastodont_search.h @@ -4,7 +4,6 @@ #ifndef MASTODONT_SEARCH_H #define MASTODONT_SEARCH_H -#include "mastodont.h" #include "mastodont_types.h" enum mstdnt_search_type diff --git a/src/mastodont.c b/src/mastodont.c index 74f55e0..2832299 100644 --- a/src/mastodont.c +++ b/src/mastodont.c @@ -3,29 +3,34 @@ #include #include -void mstdnt_global_curl_init() +void +mstdnt_global_curl_init(void) { curl_global_init(CURL_GLOBAL_ALL); } -void mstdnt_global_curl_cleanup() +void +mstdnt_global_curl_cleanup(void) { curl_global_cleanup(); } // Curl multi can still be used with single context's -int mstdnt_init(mastodont_t* data) +int +mstdnt_init(mastodont_t* data) { data->curl = curl_multi_init(); return data->curl == NULL; } -void mstdnt_cleanup(mastodont_t* data) +void +mstdnt_cleanup(mastodont_t* data) { curl_multi_cleanup(data->curl); } -void mstdnt_storage_cleanup(struct mstdnt_storage* storage) +void +mstdnt_storage_cleanup(struct mstdnt_storage* storage) { if (storage && storage->needs_cleanup) {