From a2396fe15bdd1bb89bf9ee75850eb874c781177e Mon Sep 17 00:00:00 2001 From: Martijn Otto Date: Fri, 23 Feb 2018 09:39:39 +0100 Subject: [PATCH] WIP on support for CMake builds, fails to build tests (probably error in FindCheck not declaring dependency on pthread) --- CMakeLists.txt | 46 +++++++++++-- cmake/{ => Modules}/FindCheck.cmake | 0 cmake/{ => Modules}/FindJemalloc.cmake | 0 cmake/{ => Modules}/FindJudy.cmake | 0 cmake/{ => Modules}/FindPCRE.cmake | 0 config.h.cmake | 91 ++++++++++++++++++++++++++ configure.ac | 4 +- package.json | 2 +- 8 files changed, 132 insertions(+), 11 deletions(-) rename cmake/{ => Modules}/FindCheck.cmake (100%) rename cmake/{ => Modules}/FindJemalloc.cmake (100%) rename cmake/{ => Modules}/FindJudy.cmake (100%) rename cmake/{ => Modules}/FindPCRE.cmake (100%) create mode 100644 config.h.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 8820ced..f8a4f55 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,19 +6,51 @@ # cmake clean... orz # http://stackoverflow.com/questions/9680420/looking-for-a-cmake-clean-command-to-clear-up-cmake-output +# load required modules +include(CheckIncludeFile) +include(CheckSymbolExists) +include(CheckTypeSize) -cmake_minimum_required(VERSION 2.8) -project(r3) + +cmake_minimum_required(VERSION 3.0) +project(r3 VERSION 2.0.0) SET(CMAKE_MODULE_PATH - ${PROJECT_SOURCE_DIR}/cmake + ${PROJECT_SOURCE_DIR}/cmake/Modules ${CMAKE_MODULE_PATH} - ) +) -include_directories(. ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/3rdparty /opt/local/include) -# include_directories(. ${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/3rdparty ${PROJECT_SOURCE_DIR}) +# check for availability of certain headers +CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H) +CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H) +CHECK_INCLUDE_FILE(jemalloc/jemalloc.h HAVE_JEMALLOC_JEMALLOC_H) +CHECK_INCLUDE_FILE(memory.h HAVE_MEMORY_H) +CHECK_INCLUDE_FILE(stdlib.h HAVE_STDLIB_H) +CHECK_INCLUDE_FILE(string.h HAVE_STRING_H) +CHECK_INCLUDE_FILE(stdbool.h HAVE_STDBOOL_H) +CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H) +CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H) +CHECK_INCLUDE_FILE(sys/time.h HAVE_SYS_TIME_H) +CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H) -link_directories(${LINK_DIRECTORIES} /opt/local/lib) +# check availability of certain system functions +CHECK_SYMBOL_EXISTS("gettimeofday" "sys/time.h" HAVE_GETTIMEOFDAY) +CHECK_SYMBOL_EXISTS("memset" "string.h" HAVE_MEMSET) +CHECK_SYMBOL_EXISTS("strchr" "string.h" HAVE_STRCHR) +CHECK_SYMBOL_EXISTS("strdup" "string.h" HAVE_STRDUP) +CHECK_SYMBOL_EXISTS("strndup" "string.h" HAVE_STRNDUP) +CHECK_SYMBOL_EXISTS("strnstr" "string.h" HAVE_STRNSTR) +CHECK_SYMBOL_EXISTS("strstr" "string.h" HAVE_STRSTR) + +# check availability of certain types +CHECK_TYPE_SIZE(_Bool _BOOL) + +# generate the configuration file +configure_file("${PROJECT_SOURCE_DIR}/config.h.cmake" "${PROJECT_BINARY_DIR}/config.h") + +include_directories(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/3rdparty ${PROJECT_BINARY_DIR}) + +# link_directories(${LINK_DIRECTORIES} /opt/local/lib) find_package(PCRE REQUIRED) # find_package(Judy REQUIRED) diff --git a/cmake/FindCheck.cmake b/cmake/Modules/FindCheck.cmake similarity index 100% rename from cmake/FindCheck.cmake rename to cmake/Modules/FindCheck.cmake diff --git a/cmake/FindJemalloc.cmake b/cmake/Modules/FindJemalloc.cmake similarity index 100% rename from cmake/FindJemalloc.cmake rename to cmake/Modules/FindJemalloc.cmake diff --git a/cmake/FindJudy.cmake b/cmake/Modules/FindJudy.cmake similarity index 100% rename from cmake/FindJudy.cmake rename to cmake/Modules/FindJudy.cmake diff --git a/cmake/FindPCRE.cmake b/cmake/Modules/FindPCRE.cmake similarity index 100% rename from cmake/FindPCRE.cmake rename to cmake/Modules/FindPCRE.cmake diff --git a/config.h.cmake b/config.h.cmake new file mode 100644 index 0000000..b90341d --- /dev/null +++ b/config.h.cmake @@ -0,0 +1,91 @@ +#cmakedefine HAVE_DLFCN_H @HAVE_STDLIB_H@ +#cmakedefine HAVE_GETTIMEOFDAY @HAVE_GETTIMEOFDAY@ +#cmakedefine HAVE_INTTYPES_H @HAVE_INTTYPES_H@ +#cmakedefine HAVE_JEMALLOC_JEMALLOC_H @HAVE_JEMALLOC_JEMALLOC_H@ +#cmakedefine HAVE_MEMORY_H @HAVE_MEMORY_H@ +#cmakedefine HAVE_MEMSET @HAVE_MEMSET@ +#cmakedefine HAVE_STDBOOL_H @HAVE_STDBOOL_H@ +#cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@ +#cmakedefine HAVE_STDLIB_H @HAVE_STDLIB_H@ +#cmakedefine HAVE_STRCHR @HAVE_STRCHR@ +#cmakedefine HAVE_STRDUP @HAVE_STRDUP@ +#cmakedefine HAVE_STRINGS_H @HAVE_STRINGS_H@ +#cmakedefine HAVE_STRING_H @HAVE_STRING_H@ +#cmakedefine HAVE_STRNDUP @HAVE_STRNDUP@ +#cmakedefine HAVE_STRSTR @HAVE_STRSTR@ +#cmakedefine HAVE_SYS_STAT_H @HAVE_SYS_STAT_H@ +#cmakedefine HAVE_SYS_TIME_H @HAVE_SYS_TIME_H@ +#cmakedefine HAVE_SYS_TYPES_H @HAVE_SYS_TYPES_H@ +#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@ +#cmakedefine HAVE__BOOL @HAVE__BOOL@ + +/* Name of package */ +#define PACKAGE "@PROJECT_NAME@" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "@PROJECT_NAME@" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "@PROJECT_NAME@ @PROJECT_VERSION@" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "@PROJECT_NAME@" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "@PROJECT_VERSION@" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define to 1 if you have the PATH_MAX macro. */ +/* #undef USE_JEMALLOC */ + +/* Enable extensions on AIX 3, Interix. */ +#ifndef _ALL_SOURCE +# define _ALL_SOURCE 1 +#endif +/* Enable GNU extensions on systems that have them. */ +#ifndef _GNU_SOURCE +# define _GNU_SOURCE 1 +#endif +/* Enable threading extensions on Solaris. */ +#ifndef _POSIX_PTHREAD_SEMANTICS +# define _POSIX_PTHREAD_SEMANTICS 1 +#endif +/* Enable extensions on HP NonStop. */ +#ifndef _TANDEM_SOURCE +# define _TANDEM_SOURCE 1 +#endif +/* Enable general extensions on Solaris. */ +#ifndef __EXTENSIONS__ +# define __EXTENSIONS__ 1 +#endif + + +/* Version number of package */ +#define VERSION "@PROJECT_VERSION@" + +/* Define to 1 if on MINIX. */ +/* #undef _MINIX */ + +/* Define to 2 if the system does not provide POSIX.1 features except with + this defined. */ +/* #undef _POSIX_1_SOURCE */ + +/* Define to 1 if you need to in order for `stat' and other things to work. */ +/* #undef _POSIX_SOURCE */ + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +/* #undef inline */ +#endif + +/* Define to `unsigned int' if does not define. */ +/* #undef size_t */ diff --git a/configure.ac b/configure.ac index 421baef..070792d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([r3], 1.3.3) +AC_INIT([r3], 2.0.0) AC_PREREQ([2.64]) AC_USE_SYSTEM_EXTENSIONS AC_CONFIG_HEADERS(config.h) @@ -23,8 +23,6 @@ AC_C_INLINE AC_TYPE_SIZE_T # Checks for library functions. -AC_FUNC_MALLOC -AC_FUNC_REALLOC AC_CHECK_FUNCS([gettimeofday memset strchr strdup strndup strstr]) PKG_PROG_PKG_CONFIG diff --git a/package.json b/package.json index 9289e5f..95071f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "r3", - "version": "1.3.3", + "version": "2.0.0", "repo": "brendanashworth/r3", "description": "high-performance path dispatching library", "keywords": ["path", "dispatch", "performance", "r3", "c9s"],