From 0e269a0eeb8ab08950744e5b891701a380dbd0ae Mon Sep 17 00:00:00 2001 From: nekobit Date: Sat, 24 Dec 2022 21:36:11 +0000 Subject: [PATCH] Fix usage of angled -> quoted includes FossilOrigin-Name: 9502a0fe3ad469cda46ab0835779eaa82a48533a3102d84388bd571ba7093eb5 --- CMakeLists.txt | 38 +++++++++++++++++++++----------- include/mastodont.h | 26 +++++++++++----------- include/mastodont_announcement.h | 4 ++-- include/mastodont_error.h | 4 ++-- include/mastodont_fetch.h | 2 +- include/mastodont_list.h | 6 ++--- include/mastodont_nodeinfo.h | 3 +-- include/mastodont_pleroma.h | 4 ++-- include/mastodont_relationship.h | 4 ++-- include/mastodont_scrobbles.h | 4 ++-- include/mastodont_timeline.h | 4 ++-- include/mastodont_uri.h | 2 +- 12 files changed, 56 insertions(+), 45 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 680c73a..65a8a05 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,15 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_package(PkgConfig REQUIRED) find_package(CURL REQUIRED) +# Find the real cJSON +pkg_check_modules(CJSON libcjson) + +if (NOT (CJSON_FOUND AND CJSON_VERSION VERSION_GREATER_EQUAL 1.7.14)) + # This was a workaround to some distributions providing an older cJSON + message("CJSON not found or CJSON_VERSION < 1.7.14, falling back to header-only.") + list(APPEND SRC_FILES libs/cjson/cJSON.c) +endif() + set(HEADER_FILES include/mastodont_account.h @@ -49,9 +58,7 @@ set(HEADER_FILES include/mastodont.h ) -add_library(mastodont STATIC ${HEADER_FILES}) - -target_sources(mastodont PRIVATE +list(APPEND SRC_FILES src/account.c src/application.c src/attachment.c @@ -76,9 +83,11 @@ target_sources(mastodont PRIVATE src/status.c src/tag.c src/timeline.c - src/uri.c - libs/cjson/cJSON.c -) + src/uri.c) + +add_library(mastodont STATIC ${HEADER_FILES}) + +target_sources(mastodont PRIVATE ${SRC_FILES}) target_compile_options(mastodont PUBLIC -Wall -Wextra -std=c99 @@ -95,15 +104,18 @@ target_include_directories(mastodont PUBLIC ) # Install -install(FILES ${HEADER_FILES} DESTINATION - include/mastodont/) -install(TARGETS mastodont +if(CJSON_FOUND AND CJSON_VERSION VERSION_GREATER_EQUAL 1.7.14) + install(FILES ${HEADER_FILES} DESTINATION + include/mastodont/) + install(TARGETS mastodont LIBRARY DESTINATION lib) -configure_package_config_file(cmake/MastodontConfig.cmake.in + configure_package_config_file(cmake/MastodontConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/MastodontConfig.cmake - INSTALL_DESTINATION lib/cmake + INSTALL_DESTINATION lib/cmake/mastodont PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/MastodontConfig.cmake DESTINATION lib/cmake) - + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/MastodontConfig.cmake DESTINATION lib/cmake/mastodont) +else() + message("Since CJSON wasn't found or your distribution doesn't provide correct version, you can still use cmake/mastodont-config.cmake and check for it in your package. You _probably_ don't want this") +endif() diff --git a/include/mastodont.h b/include/mastodont.h index dc6efba..253135c 100644 --- a/include/mastodont.h +++ b/include/mastodont.h @@ -4,19 +4,19 @@ #ifndef MASTODONT_H #define MASTODONT_H -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "mastodont_hooks.h" +#include "mastodont_types.h" +#include "mastodont_timeline.h" +#include "mastodont_list.h" +#include "mastodont_notification.h" +#include "mastodont_status.h" +#include "mastodont_relationship.h" +#include "mastodont_account.h" +#include "mastodont_attachment.h" +#include "mastodont_scrobbles.h" +#include "mastodont_search.h" +#include "mastodont_announcement.h" +#include "mastodont_chats.h" /// Initializes libcurl void diff --git a/include/mastodont_announcement.h b/include/mastodont_announcement.h index acdc2ce..0350123 100644 --- a/include/mastodont_announcement.h +++ b/include/mastodont_announcement.h @@ -4,8 +4,8 @@ #ifndef MASTODONT_ANNOUNCEMENT_H #define MASTODONT_ANNOUNCEMENT_H -#include - +#include "mastodont_types.h" +// TODO #endif /* MASTODONT_ANNOUNCEMENT_H */ diff --git a/include/mastodont_error.h b/include/mastodont_error.h index d9bdefb..7e1016b 100644 --- a/include/mastodont_error.h +++ b/include/mastodont_error.h @@ -4,8 +4,8 @@ #ifndef MASTODONT_ERROR_H #define MASTODONT_ERROR_H -#include -#include +#include "mastodont_types.h" +#include "mastodont_fetch.h" int mstdnt_check_error(struct mstdnt_storage* storage); diff --git a/include/mastodont_fetch.h b/include/mastodont_fetch.h index c5598c3..78828db 100644 --- a/include/mastodont_fetch.h +++ b/include/mastodont_fetch.h @@ -5,8 +5,8 @@ #ifndef MASTODONT_FETCH_H #define MASTODONT_FETCH_H #include -#include #include +#include "mastodont_types.h" /** Used to store the response from CURL */ struct mstdnt_fetch_data diff --git a/include/mastodont_list.h b/include/mastodont_list.h index 63591e8..7f58c9b 100644 --- a/include/mastodont_list.h +++ b/include/mastodont_list.h @@ -4,10 +4,10 @@ #ifndef MASTODONT_LIST_H #define MASTODONT_LIST_H -#include +#include "mastodont_types.h" #include -#include -#include +#include "mastodont_fetch.h" +#include "mastodont_account.h" enum mstdnt_list_replies_policy { diff --git a/include/mastodont_nodeinfo.h b/include/mastodont_nodeinfo.h index 55d4a7b..66a7eaf 100644 --- a/include/mastodont_nodeinfo.h +++ b/include/mastodont_nodeinfo.h @@ -4,8 +4,7 @@ #ifndef MASTODONT_NODEINFO_H #define MASTODONT_NODEINFO_H -#include - +#include "mastodont_types.h" struct mstdnt_nodeinfo_metadata { diff --git a/include/mastodont_pleroma.h b/include/mastodont_pleroma.h index 2054379..9fb0c16 100644 --- a/include/mastodont_pleroma.h +++ b/include/mastodont_pleroma.h @@ -6,8 +6,8 @@ // TODO Move me to statuses #ifndef MASTODONT_PLEROMA #define MASTODONT_PLEROMA -#include -#include +#include "mastodont_types.h" +#include "mastodont_emoji.h" struct mstdnt_status_pleroma { diff --git a/include/mastodont_relationship.h b/include/mastodont_relationship.h index f507c55..b699484 100644 --- a/include/mastodont_relationship.h +++ b/include/mastodont_relationship.h @@ -6,8 +6,8 @@ #define MASTODONT_RELATIONSHIP_H #include #include -#include -#include +#include "mastodont_types.h" +#include "mastodont_request.h" typedef uint16_t mstdnt_relationship_flag_t; diff --git a/include/mastodont_scrobbles.h b/include/mastodont_scrobbles.h index bd10c6b..c6fabd2 100644 --- a/include/mastodont_scrobbles.h +++ b/include/mastodont_scrobbles.h @@ -5,8 +5,8 @@ #ifndef MASTODONT_SCROBBLES_H #define MASTODONT_SCROBBLES_H #include -#include -#include +#include "mastodont_types.h" +#include "mastodont_account.h" typedef struct mstdnt_scrobble { diff --git a/include/mastodont_timeline.h b/include/mastodont_timeline.h index ae01505..9cef745 100644 --- a/include/mastodont_timeline.h +++ b/include/mastodont_timeline.h @@ -4,8 +4,8 @@ #ifndef MASTODONT_TIMELINE_H #define MASTODONT_TIMELINE_H -#include -#include +#include "mastodont_types.h" +#include "mastodont_status.h" enum mstdnt_reply_visibility { diff --git a/include/mastodont_uri.h b/include/mastodont_uri.h index 320e29f..90be7fd 100644 --- a/include/mastodont_uri.h +++ b/include/mastodont_uri.h @@ -4,7 +4,7 @@ #ifndef MASTODONT_URI_H #define MASTODONT_URI_H -#include +#include "mastodont_types.h" #include struct mstdnt_uri