Play around with Premake build system
should be in a separate branch, but oh well... FossilOrigin-Name: 7fefec89a8a466b83c7ca066106fcce2b18376ec390d6a1a6a1ecc6fd3497744
This commit is contained in:
parent
bcdfb621b7
commit
e95a6ae246
7 changed files with 45 additions and 195 deletions
|
@ -4,3 +4,6 @@ src/*.o
|
|||
docs/html/
|
||||
docs/latex/
|
||||
build/
|
||||
obj/
|
||||
Mastodont.make
|
||||
Makefile
|
||||
|
|
129
CMakeLists.txt
129
CMakeLists.txt
|
@ -1,129 +0,0 @@
|
|||
cmake_minimum_required(VERSION 3.14)
|
||||
project(mastodont
|
||||
VERSION 0.1
|
||||
DESCRIPTION "Library for Mastodon, Pleroma, Wormhole, etc."
|
||||
LANGUAGES C)
|
||||
|
||||
# BEGIN cmake package config info
|
||||
include(CMakePackageConfigHelpers)
|
||||
set(INCLUDE_INSTALL_DIR include/mastodont/)
|
||||
set(LIB_INSTALL_DIR lib/)
|
||||
# This feels... UNIX-y
|
||||
set(LIB_INSTALL_PATH lib/libmastodont.a)
|
||||
# END cmake package config info
|
||||
|
||||
# Useful
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(CURL REQUIRED)
|
||||
# Find the real cJSON
|
||||
pkg_check_modules(CJSON libcjson)
|
||||
|
||||
# Includes test programs... unit tests
|
||||
add_subdirectory(tests)
|
||||
|
||||
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
|
||||
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
|
||||
)
|
||||
|
||||
list(APPEND SRC_FILES
|
||||
src/account.c
|
||||
src/application.c
|
||||
src/attachment.c
|
||||
src/chats.c
|
||||
src/emoji.c
|
||||
src/error.c
|
||||
src/fetch.c
|
||||
src/history.c
|
||||
src/hooks.c
|
||||
src/instance.c
|
||||
src/json_helper.c
|
||||
src/list.c
|
||||
src/mastodont.c
|
||||
src/nodeinfo.c
|
||||
src/notification.c
|
||||
src/pleroma.c
|
||||
src/query.c
|
||||
src/relationship.c
|
||||
src/request.c
|
||||
src/scrobbles.c
|
||||
src/search.c
|
||||
src/status.c
|
||||
src/tag.c
|
||||
src/timeline.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
|
||||
-Wshadow -Wcast-align -Wstrict-prototypes
|
||||
)
|
||||
|
||||
target_link_options(mastodont PUBLIC
|
||||
${CURL_LDFLAGS_OTHER}
|
||||
)
|
||||
|
||||
target_include_directories(mastodont PUBLIC
|
||||
include/
|
||||
${CURL_INCLUDE_DIRS}
|
||||
PRIVATE
|
||||
libs/
|
||||
)
|
||||
|
||||
# Install
|
||||
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
|
||||
${CMAKE_CURRENT_BINARY_DIR}/mastodont-config.cmake
|
||||
INSTALL_DESTINATION lib/cmake/mastodont
|
||||
PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR LIB_INSTALL_PATH)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mastodont-config.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()
|
24
README.md
24
README.md
|
@ -1,11 +1,27 @@
|
|||
# Mastodont-c
|
||||
# Mastodont-c
|
||||
|
||||
- *NOTE:* API is not stable yet. Please be patient.
|
||||
|
||||
Mastodont-c is a C library to access the Mastodon API and it's variants
|
||||
(Pleroma, Akkoma, Soapbox).
|
||||
|
||||
It was written in C due to it's portability. It's designed to be used in
|
||||
Treebird, but it can be used in other programs as well.
|
||||
Treebird, but it can be used in other programs as well. In fact, there are
|
||||
tests specifically designed to showcase it's power
|
||||
|
||||
# Documentation
|
||||
# Build system
|
||||
|
||||
Documentation is essentially non-existant, but this will improve over time.
|
||||
Mastodont-c uses a pretty quirky build system called Premake5 mainly just
|
||||
to make me happy and for portability. I plan on writing some neat little
|
||||
Java bindings for this library someday to see if I can expand it onto other
|
||||
platforms :-)
|
||||
|
||||
#### On UNIX-like systems...
|
||||
|
||||
$ premake5 gmake
|
||||
|
||||
(Silly systems can use `--os bsd` to force it)
|
||||
|
||||
# Documentation
|
||||
|
||||
Documentation is essentially non-existant, but this will improve over time.
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
set(MASTODONT_VERSION 0.0.1)
|
||||
|
||||
@PACKAGE_INIT@
|
||||
|
||||
set_and_check(MASTODONT_INCLUDE_DIRS "@PACKAGE_INCLUDE_INSTALL_DIR@")
|
||||
set_and_check(MASTODONT_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@")
|
||||
set_and_check(MASTODONT_LIBRARIES "@PACKAGE_LIB_INSTALL_PATH@")
|
||||
#set_and_check(MASTODONT_SYSCONFIG_DIR "@PACKAGE_SYSCONFIG_INSTALL_DIR@")
|
||||
|
||||
check_required_components(mastodont)
|
|
@ -1,21 +0,0 @@
|
|||
# Get CFLAGS
|
||||
set(MASTODONT_FOUND)
|
||||
set(MASTODONT_VERSION 0.1)
|
||||
|
||||
# Get parent directory of this config file
|
||||
find_package(CURL REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
# TODO account for built-in cjson lib
|
||||
pkg_check_modules(MSTDNT_CJSON libcjson)
|
||||
|
||||
set(MASTODONT_INCLUDE_DIRS
|
||||
../include
|
||||
../libs
|
||||
)
|
||||
|
||||
set(MASTODONT_LIBRARIES
|
||||
mastodont
|
||||
${MSTDNT_CJSON_LIBRARIES}
|
||||
${CURL_LIBRARIES}
|
||||
)
|
||||
|
22
premake5.lua
Normal file
22
premake5.lua
Normal file
|
@ -0,0 +1,22 @@
|
|||
workspace("Mastodont");
|
||||
configurations { "Debug", "Release" };
|
||||
|
||||
-- BEGIN Mastodont project
|
||||
project("Mastodont");
|
||||
kind("StaticLib");
|
||||
language("C");
|
||||
files { "include/*.h", "src/*.c" };
|
||||
includedirs { "include/" };
|
||||
|
||||
filter { "system:linux or bsd or macosx", "action:gmake" }
|
||||
linkoptions { "`curl-config --libs`" }
|
||||
linkoptions { "`pkg-config --libs cjson`" }
|
||||
|
||||
filter { "configurations:Debug" };
|
||||
defines { "DEBUG" };
|
||||
symbols("On");
|
||||
|
||||
filter { "configurations:Release" };
|
||||
defines { "NDEBUG" };
|
||||
optimize("On");
|
||||
-- END Mastodont-c
|
|
@ -1,31 +0,0 @@
|
|||
include(../cmake/mastodont-config.cmake)
|
||||
|
||||
add_executable(get_feed get_feed.c)
|
||||
target_compile_options(get_feed PUBLIC -std=c99 -Wall)
|
||||
target_link_libraries(get_feed PUBLIC
|
||||
${MASTODONT_LIBRARIES}
|
||||
)
|
||||
target_include_directories(get_feed PUBLIC
|
||||
${MASTODONT_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
|
||||
# GUI demo
|
||||
pkg_check_modules(EFL_ECORE efl-core)
|
||||
if (EFL_ECORE_FOUND)
|
||||
# EFL is clearly installed...
|
||||
pkg_check_modules(EFL_ELEMENTARY elementary)
|
||||
|
||||
add_executable(get_feed_efl get_feed_efl.c)
|
||||
target_compile_options(get_feed_efl PUBLIC -std=c99 -Wall)
|
||||
target_link_libraries(get_feed_efl PUBLIC
|
||||
${MASTODONT_LIBRARIES}
|
||||
${EFL_ECORE_LIBRARIES}
|
||||
${EFL_ELEMENTARY_LIBRARIES}
|
||||
)
|
||||
target_include_directories(get_feed_efl PUBLIC
|
||||
${MASTODONT_INCLUDE_DIRS}
|
||||
${EFL_ECORE_INCLUDE_DIRS}
|
||||
${EFL_ELEMENTARY_INCLUDE_DIRS}
|
||||
)
|
||||
endif(EFL_ECORE_FOUND)
|
Loading…
Reference in a new issue