diff --git a/CMakeLists.txt b/CMakeLists.txt index 8820ced..84a1e51 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,26 +6,54 @@ # 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) + +# 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}/3rdparty ${PROJECT_BINARY_DIR}) -link_directories(${LINK_DIRECTORIES} /opt/local/lib) find_package(PCRE REQUIRED) -# find_package(Judy REQUIRED) -# set(LIBS ${LIBS} ${PCRE_LIBRARIES} ${Judy_LIBRARIES} r3) -set(LIBS ${LIBS} ${PCRE_LIBRARIES} r3) +set(LIBS ${PCRE_LIBRARIES} r3 lib3rdparty) -# set (CMAKE_CXX_FLAGS "-std=c++0x -arch x86_64 -stdlib=libc++ -g3 -Wall -O0") enable_testing() add_subdirectory(3rdparty) 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"], diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6ea9dba..dd9a47b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,8 @@ -include_directories("${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/3rdparty ${PROJECT_SOURCE_DIR}") -# install(TARGETS swiftnav-static DESTINATION lib${LIB_SUFFIX}) -find_package(PCRE REQUIRED) -set(libr3_SRCS node.c edge.c list.c slug.c str.c token.c match_entry.c memory.c) -set(LIBS ${LIBS} ${PCRE_LIBRARIES} r3) +include_directories("${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/3rdparty ${PROJECT_SOURCE_DIR}") +set(SOURCES node.c edge.c str.c token.c match_entry.c slug.c memory.c) +set(LIBS ${LIBS} ${PCRE_LIBRARIES}) -add_library(r3 STATIC ${libr3_SRCS}) -target_link_libraries(r3 lib3rdparty pcre) +add_library(r3 STATIC ${SOURCES}) + +install(TARGETS r3 DESTINATION lib) # install(FILES ${libswiftnav_HEADERS} DESTINATION include/libswiftnav) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 804f5d6..3e7013c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -12,7 +12,7 @@ else (NOT CHECK_FOUND) include_directories(${CHECK_INCLUDE_DIRS}) # include_directories("${PROJECT_SOURCE_DIR}/include/r2") add_executable(check_tree check_tree.c) - target_link_libraries(check_tree ${TEST_LIBS}) + target_link_libraries(check_tree ${TEST_LIBS} ${CHECK_LDFLAGS_OTHER}) add_custom_command( TARGET check_tree POST_BUILD diff --git a/tests/check_tree.c b/tests/check_tree.c index bc351a7..c5a52fb 100644 --- a/tests/check_tree.c +++ b/tests/check_tree.c @@ -7,7 +7,7 @@ #include "r3_slug.h" #include "zmalloc.h" #include "bench.h" -#include "r3_debug.h" +#include "../src/r3_debug.h" #define SAFE_FREE(ptr) if(ptr) free(ptr);