From 5aa8e03d7ed31ea746baa744140f3fa8ff026216 Mon Sep 17 00:00:00 2001 From: nekobit Date: Sun, 11 Dec 2022 06:44:41 +0000 Subject: [PATCH] Add input files and generate config from that or such FossilOrigin-Name: e475a61cebad409e48b8fb9a04a5624e01a966ed52a6defc3d473c9258778c40 --- CMakeLists.txt | 32 ++++++++++++++++++++------------ cmake/MastodontConfig.cmake.in | 9 +++++++++ cmake/mastodont-config.cmake | 2 +- 3 files changed, 30 insertions(+), 13 deletions(-) create mode 100644 cmake/MastodontConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f07fc5..680c73a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,14 +4,17 @@ project(mastodont DESCRIPTION "Library for Mastodon, Pleroma, Wormhole, etc." LANGUAGES C) +include(CMakePackageConfigHelpers) +set(INCLUDE_INSTALL_DIR include/) +set(LIB_INSTALL_DIR lib/) + # Useful set(CMAKE_EXPORT_COMPILE_COMMANDS ON) find_package(PkgConfig REQUIRED) find_package(CURL REQUIRED) -add_library(mastodont STATIC) -set(HEADERS_FILES +set(HEADER_FILES include/mastodont_account.h include/mastodont_announcement.h include/mastodont_application.h @@ -46,7 +49,9 @@ set(HEADERS_FILES include/mastodont.h ) -target_sources(mastodont PUBLIC +add_library(mastodont STATIC ${HEADER_FILES}) + +target_sources(mastodont PRIVATE src/account.c src/application.c src/attachment.c @@ -72,8 +77,6 @@ target_sources(mastodont PUBLIC src/tag.c src/timeline.c src/uri.c - - PRIVATE libs/cjson/cJSON.c ) @@ -81,12 +84,9 @@ target_compile_options(mastodont PUBLIC -Wall -Wextra -std=c99 -Wshadow -Wcast-align -Wstrict-prototypes ) - target_link_options(mastodont PUBLIC - -lmastodont ${CURL_LDFLAGS_OTHER} ) - target_include_directories(mastodont PUBLIC include/ ${CURL_INCLUDE_DIRS} @@ -94,8 +94,16 @@ target_include_directories(mastodont PUBLIC libs/ ) -install(FILES ${HEADER_FILES} DESTINATION include/mastodont/) -install(TARGETS mastodont LIBRARY DESTINATION lib) -# TODO -#install(FILES MastodontConfig.cmake DESTINATION lib/cmake/mastodont) +# Install +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}/MastodontConfig.cmake + INSTALL_DESTINATION lib/cmake + PATH_VARS INCLUDE_INSTALL_DIR LIB_INSTALL_DIR) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/MastodontConfig.cmake DESTINATION lib/cmake) diff --git a/cmake/MastodontConfig.cmake.in b/cmake/MastodontConfig.cmake.in new file mode 100644 index 0000000..d557a75 --- /dev/null +++ b/cmake/MastodontConfig.cmake.in @@ -0,0 +1,9 @@ +set(MASTODONT_VERSION 0.0.1) + +@PACKAGE_INIT@ + +set_and_check(MASTODONT_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") +set_and_check(MASTODONT_LIB "@PACKAGE_LIB_INSTALL_DIR@") +#set_and_check(MASTODONT_SYSCONFIG_DIR "@PACKAGE_SYSCONFIG_INSTALL_DIR@") + +check_required_components(mastodont) diff --git a/cmake/mastodont-config.cmake b/cmake/mastodont-config.cmake index 31139b0..73b6176 100644 --- a/cmake/mastodont-config.cmake +++ b/cmake/mastodont-config.cmake @@ -9,6 +9,6 @@ set(MASTODONT_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/../include" "${CMAKE_CURRENT_LIST_DIR}/../libs" ) -set(MASTODONT_LIBRARIES "mastodont" "curl") +set(MASTODONT_LIBRARIES ${CMAKE_CURRENT_LIST_DIR})