From 309c33f496d69629ec82dc8f46a2d2c58ad12fa0 Mon Sep 17 00:00:00 2001 From: Nicholas Chambers Date: Sat, 19 May 2018 12:29:47 -0500 Subject: [PATCH] Apply fixes to let 1.0.1 build --- CMakeLists.txt | 12 ++++++++++++ hashmap.pc.in | 12 ++++++++++++ include/linkedlist.h | 2 +- src/hashmap.c | 2 ++ src/linkedlist.c | 1 + 5 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt create mode 100644 hashmap.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..9ea6eff --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.9.1) +project(hashmap VERSION 1.0.1 DESCRIPTION "A small hashmap written in C to use with some other projects") +add_library(hashmap SHARED src src/hashmap.c src/linkedlist.c src/node.c) +set_target_properties(hashmap PROPERTIES VERSION ${PROJECT_VERSION}) +set_target_properties(hashmap PROPERTIES SOVERSION 1) +set_target_properties(hashmap PROPERTIES PUBLIC_HEADER include/hashmap.c) +target_include_directories(hashmap PRIVATE include) +# target_include_directories(hashmap PRIVATE src) +include(GNUInstallDirs) +configure_file(hashmap.pc.in hashmap.pc @ONLY) +install(TARGETS hashmap LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) +install(FILES ${CMAKE_BINARY_DIR}/hashmap.pc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/pkgconfig) diff --git a/hashmap.pc.in b/hashmap.pc.in new file mode 100644 index 0000000..53c0daa --- /dev/null +++ b/hashmap.pc.in @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@CMAKE_INSTALL_PREFIX@ +libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ +includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ + +Name: @PROJECT_NAME@ +Description: @PROJECT_DESCRIPTION@ +Version: @PROJECT_VERSION@ + +Requires: +Libs: -L${libdir} -lhashmap +Cflags: -I${includedir} diff --git a/include/linkedlist.h b/include/linkedlist.h index 622c0f5..68fed91 100644 --- a/include/linkedlist.h +++ b/include/linkedlist.h @@ -9,7 +9,7 @@ struct ll { struct node *tail; }; -struct new_ll(); +struct ll new_ll(); void insert_ll(struct ll *list, const char *key, const char *value); void remove_ll(struct ll *list, struct node *link); diff --git a/src/hashmap.c b/src/hashmap.c index d7e2bde..c54fb2d 100644 --- a/src/hashmap.c +++ b/src/hashmap.c @@ -1,4 +1,6 @@ #include +#include +#include struct hashmap new_map() { struct hashmap new; diff --git a/src/linkedlist.c b/src/linkedlist.c index 38ec049..e1ab46b 100644 --- a/src/linkedlist.c +++ b/src/linkedlist.c @@ -1,4 +1,5 @@ #include +#include struct ll new_ll() { struct ll new;