Cleanup CMake build files
This commit is contained in:
parent
2be2a08750
commit
d1c06cd3e9
5 changed files with 80 additions and 174 deletions
6
3rdparty/CMakeLists.txt
vendored
6
3rdparty/CMakeLists.txt
vendored
|
@ -1,6 +0,0 @@
|
|||
include_directories("${PROJECT_SOURCE_DIR}/3rdparty ${PROJECT_SOURCE_DIR}")
|
||||
set(lib3rdparty_SRCS zmalloc.c)
|
||||
add_library(lib3rdparty STATIC ${lib3rdparty_SRCS})
|
||||
# add_library(r3 SHARED ${libr3_SRCS})
|
||||
# target_link_libraries(r3 cblas)
|
||||
# install(FILES ${libswiftnav_HEADERS} DESTINATION include/libswiftnav)
|
|
@ -1,62 +1,45 @@
|
|||
# cmake file examples
|
||||
# https://code.google.com/p/opencv-feature-tracker/source/browse/CMakeLists.txt?r=f804b03e704147e65183c19a50f57abedb22f45c
|
||||
|
||||
|
||||
# TODO:
|
||||
# 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 3.0)
|
||||
project(r3 VERSION 2.0.0)
|
||||
|
||||
SET(CMAKE_MODULE_PATH
|
||||
${PROJECT_SOURCE_DIR}/cmake/Modules
|
||||
${CMAKE_MODULE_PATH}
|
||||
)
|
||||
|
||||
# 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})
|
||||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules)
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
||||
find_package(Check)
|
||||
find_package(PCRE REQUIRED)
|
||||
|
||||
set(LIBS ${PCRE_LIBRARIES} r3 lib3rdparty)
|
||||
include(CheckSymbolExists)
|
||||
check_symbol_exists(strdup string.h HAVE_STRDUP)
|
||||
check_symbol_exists(strndup string.h HAVE_STRNDUP)
|
||||
configure_file(config.h.cmake config.h)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_subdirectory(3rdparty)
|
||||
add_subdirectory(src)
|
||||
|
||||
install(
|
||||
FILES
|
||||
include/memory.h
|
||||
include/r3.h
|
||||
include/r3_list.h
|
||||
include/r3_slug.h
|
||||
include/r3_gvc.h
|
||||
include/r3_json.h
|
||||
include/str_array.h
|
||||
include/r3.hpp
|
||||
DESTINATION include)
|
||||
|
||||
set(prefix ${CMAKE_INSTALL_PREFIX})
|
||||
set(exec_prefix ${prefix})
|
||||
set(includedir ${prefix}/include)
|
||||
set(libdir ${prefix}/lib)
|
||||
set(PACKAGE_VERSION ${PROJECT_VERSION})
|
||||
configure_file(r3.pc.in r3.pc @ONLY)
|
||||
install(
|
||||
FILES
|
||||
${PROJECT_BINARY_DIR}/r3.pc
|
||||
DESTINATION lib/pkgconfig)
|
||||
|
||||
if(CHECK_FOUND)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
# add_test(test_tree ${CMAKE_CURRENT_BINARY_DIR}/check_tree)
|
||||
else()
|
||||
message(STATUS "Skipping unit tests, Check library not found!")
|
||||
endif()
|
||||
|
|
|
@ -1,91 +1,2 @@
|
|||
#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 <sys/types.h> does not define. */
|
||||
/* #undef size_t */
|
||||
|
|
|
@ -1,8 +1,27 @@
|
|||
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
|
||||
${PROJECT_SOURCE_DIR}/3rdparty/zmalloc.c
|
||||
edge.c
|
||||
match_entry.c
|
||||
memory.c
|
||||
node.c
|
||||
slug.c
|
||||
str.c
|
||||
token.c)
|
||||
|
||||
add_library(r3 STATIC ${SOURCES})
|
||||
target_compile_definitions(r3
|
||||
PRIVATE
|
||||
_GNU_SOURCE)
|
||||
|
||||
install(TARGETS r3 DESTINATION lib)
|
||||
# install(FILES ${libswiftnav_HEADERS} DESTINATION include/libswiftnav)
|
||||
target_include_directories(r3
|
||||
PUBLIC
|
||||
${PROJECT_BINARY_DIR}
|
||||
${PROJECT_SOURCE_DIR}/3rdparty
|
||||
${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
target_link_libraries(r3
|
||||
PUBLIC
|
||||
${PCRE_LIBRARIES})
|
||||
|
||||
install(
|
||||
TARGETS r3
|
||||
DESTINATION lib)
|
||||
|
|
|
@ -1,24 +1,23 @@
|
|||
# set(TEST_LIBS ${TEST_LIBS} ${CHECK_LIBRARIES} judy libr3)
|
||||
include_directories("${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}")
|
||||
find_package(Check REQUIRED)
|
||||
find_package(PCRE REQUIRED)
|
||||
# find_package(Judy REQUIRED)
|
||||
function(add_r3_test NAME)
|
||||
add_executable(${NAME} ${ARGN})
|
||||
|
||||
if (NOT CHECK_FOUND)
|
||||
message(STATUS "Skipping unit tests, Check library not found!")
|
||||
else (NOT CHECK_FOUND)
|
||||
set(TEST_LIBS ${LIBS} ${CHECK_LIBRARIES} ${PCRE_LIBRARIES} r3)
|
||||
target_include_directories(${NAME}
|
||||
PRIVATE
|
||||
${CHECK_INCLUDE_DIRS}
|
||||
${PROJECT_BINARY_DIR}
|
||||
${PROJECT_SOURCE_DIR}/src)
|
||||
|
||||
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} ${CHECK_LDFLAGS_OTHER})
|
||||
target_link_libraries(${NAME}
|
||||
${CHECK_LDFLAGS}
|
||||
r3)
|
||||
|
||||
add_custom_command(
|
||||
TARGET check_tree POST_BUILD
|
||||
COMMENT "Running unit tests"
|
||||
COMMAND check_tree
|
||||
)
|
||||
endif (NOT CHECK_FOUND)
|
||||
add_test(NAME ${NAME} COMMAND ${NAME})
|
||||
endfunction()
|
||||
|
||||
add_r3_test(check_tree check_tree.c)
|
||||
add_r3_test(check_slug check_slug.c)
|
||||
add_r3_test(check_routes check_routes.c)
|
||||
add_r3_test(check_str_array check_str_array.c)
|
||||
|
||||
add_executable(bench bench.c)
|
||||
target_link_libraries(bench r3)
|
||||
|
|
Loading…
Reference in a new issue