Permalink
Browse files

More defines, better cmake config.

  • Loading branch information...
1 parent 6262135 commit 957faf689de85a10a4dc5067935b030789619639 @jbuchbinder committed Dec 28, 2011
Showing with 106 additions and 9 deletions.
  1. +2 −0 .gitignore
  2. +58 −8 CMakeLists.txt
  3. +17 −0 src/config.h.in
  4. +19 −1 src/statsd.c
  5. +10 −0 src/statsd_client.c
View
@@ -2,6 +2,8 @@ CMakeCache.txt
CMakeFiles
cmake_install.cmake
config.h
+CPackConfig.cmake
+CPackSourceConfig.cmake
Makefile
statsd
statsd_client
View
@@ -1,11 +1,46 @@
-cmake_minimum_required (VERSION 2.6)
-project (statsd-c)
-set(STATSD_VERSION 0.1)
+cmake_minimum_required ( VERSION 2.6 )
+project ( statsd-c )
-include(CheckIncludeFiles)
-include(CheckFunctionExists)
-check_include_files(limits.h HAVE_LIMITS_H)
-check_function_exists(vasprintf HAVE_VASPRINTF)
+set ( PACKAGE "statsd-c" )
+set ( STATSD_VERSION_MAJOR 0 )
+set ( STATSD_VERSION_MINOR 1 )
+set ( STATSD_VERSION_MICRO 0 )
+set ( VERSION "${STATSD_VERSION_MAJOR}.${STATSD_VERSION_MINOR}.${STATSD_VERSION_MICRO}" )
+set ( STATSD_VERSION "\"${VERSION}\"" )
+
+include ( CheckIncludeFiles )
+include ( CheckFunctionExists )
+check_include_files ( limits.h HAVE_LIMITS_H )
+check_include_files ( sys/types.h HAVE_SYS_TYPES_H )
+check_include_files ( sys/time.h HAVE_SYS_TIME_H )
+check_include_files ( time.h HAVE_TIME_H )
+check_include_files ( sys/stat.h HAVE_SYS_STAT_H )
+check_include_files ( sys/ioctl.h HAVE_SYS_IOCTL_H )
+check_include_files ( fcntl.h HAVE_FCNTL_H )
+check_include_files ( sys/socket.h HAVE_SYS_SOCKET_H )
+check_include_files ( netinet/in.h HAVE_NETINET_IN_H )
+check_include_files ( netinet/tcp.h HAVE_NETINET_TCP_H )
+check_include_files ( arpa/inet.h HAVE_ARPA_INET_H )
+check_include_files ( limits.h HAVE_LIMITS_H )
+check_include_files ( unistd.h HAVE_UNISTD_H )
+check_include_files ( semaphore.h HAVE_SEMAPHORE_H )
+check_include_files ( netdb.h HAVE_NETDB_H )
+check_include_files ( pthread.h HAVE_PTHREAD_H )
+check_include_files ( signal.h HAVE_SIGNAL_H )
+check_function_exists ( vasprintf HAVE_VASPRINTF )
+
+# Platform specific options
+if ( ${CMAKE_SYSTEM} MATCHES "Linux" )
+ set ( CMAKE_C_FLAGS "-Wno-format-security -Wno-int-to-pointer-cast -Isrc/json-c -Isrc/embeddedgmetric -fPIC -pthread" )
+endif ( ${CMAKE_SYSTEM} MATCHES "Linux" )
+
+if ( ${CMAKE_SYSTEM} MATCHES "Darwin" )
+ set ( CMAKE_C_FLAGS "-Wno-format-security -Wno-int-to-pointer-cast -Isrc/json-c -Isrc/embeddedgmetric -fPIC -pthread" )
+endif ( ${CMAKE_SYSTEM} MATCHES "Darwin" )
+
+if ( ${CMAKE_SYSTEM} MATCHES "OS2" )
+ set ( CMAKE_C_FLAGS "-Wno-format-security -Wno-int-to-pointer-cast -Isrc/json-c -Isrc/embeddedgmetric -fPIC -pthread" )
+endif ( ${CMAKE_SYSTEM} MATCHES "OS2" )
# Passing variables
configure_file (
@@ -16,8 +51,23 @@ include_directories("${PROJECT_BINARY_DIR}")
# Daemon binary
add_executable(statsd src/statsd.c src/queue.c src/serialize.c src/strings.c src/embeddedgmetric/embeddedgmetric.c src/embeddedgmetric/modp_numtoa.c src/json-c/arraylist.c src/json-c/debug.c src/json-c/json_object.c src/json-c/json_tokener.c src/json-c/json_util.c src/json-c/linkhash.c src/json-c/printbuf.c)
-set(CMAKE_C_FLAGS "-Wno-format-security -Wno-int-to-pointer-cast -Isrc/json-c -Isrc/embeddedgmetric -fPIC -pthread")
# Client binary
add_executable(statsd_client src/statsd_client.c)
+# CPack support
+set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "statsd-c" )
+set ( CPACK_PACKAGE_VENDOR "https://github.com/jbuchbinder/statsd-c" )
+set ( CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md" )
+set ( CPACK_PACKAGE_VERSION_MAJOR ${STATSD_VERSION_MAJOR} )
+set ( CPACK_PACKAGE_VERSION_MINOR ${STATSD_VERSION_MINOR} )
+set ( CPACK_PACKAGE_VERSION_PATCH ${STATSD_VERSION_MICRO} )
+set ( CPACK_PACKAGE_EXECUTABLES "statsd" "statsd" )
+
+include ( InstallRequiredSystemLibraries )
+set ( CPACK_GENERATOR STGZ;TGZ;TBZ2;ZIP )
+set ( CPACK_PACKAGE_NAME ${PACKAGE} )
+set ( CPACK_STRIP_FILES ON )
+
+include ( CPack )
+
View
@@ -9,5 +9,22 @@
#define STATSD_VERSION @STATSD_VERSION@
#cmakedefine HAVE_LIMITS_H 1
+#cmakedefine HAVE_SYS_TYPES_H 1
+#cmakedefine HAVE_SYS_TIME_H 1
+#cmakedefine HAVE_TIME_H 1
+#cmakedefine HAVE_SYS_STAT_H 1
+#cmakedefine HAVE_SYS_IOCTL_H 1
+#cmakedefine HAVE_FCNTL_H 1
+#cmakedefine HAVE_SYS_SOCKET_H 1
+#cmakedefine HAVE_NETINET_IN_H 1
+#cmakedefine HAVE_NETINET_TCP_H 1
+#cmakedefine HAVE_ARPA_INET_H 1
+#cmakedefine HAVE_LIMITS_H 1
+#cmakedefine HAVE_UNISTD_H 1
+#cmakedefine HAVE_SEMAPHORE_H 1
+#cmakedefine HAVE_PTHREAD_H 1
+#cmakedefine HAVE_NETDB_H 1
+#cmakedefine HAVE_SIGNAL_H 1
+
#cmakedefine HAVE_VASPRINTF
View
@@ -8,26 +8,44 @@
#include "config.h"
+#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif
#include <sys/types.h>
#include <errno.h>
+#ifdef HAVE_FCNTL_H
#include <fcntl.h>
+#endif
+#ifdef HAVE_PTHREAD_H
#include <pthread.h>
+#endif
+#ifdef HAVE_SEMAPHORE_H
#include <semaphore.h>
+#endif
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#ifdef HAVE_LIMITS_H
#include <limits.h>
-#endif /* HAVE_LIMITS_H */
+#endif
#include "json-c/json.h"
#include "uthash/utarray.h"
View
@@ -8,17 +8,27 @@
#include "config.h"
+#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
+#endif
+#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
#include <sys/types.h>
#include <rpc/rpc.h>
#include <getopt.h>
+#ifdef HAVE_NETDB_H
#include <netdb.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_TIME_H
#include <time.h>
+#endif
uint32_t *resolve_host(const char *addr);
void usage(char *argv[]);

0 comments on commit 957faf6

Please sign in to comment.