From 9ffa5aecb8cef13c7dfb6865a99cece2215d20ed Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 15 May 2014 00:15:19 +0800 Subject: [PATCH] Check in files. --- cmake_modules/FindCheck.cmake | 54 +++++++++++++++++++++++++++++++++++ cmake_modules/FindJudy.cmake | 37 ++++++++++++++++++++++++ cmake_modules/FindPCRE.cmake | 37 ++++++++++++++++++++++++ configure.ac | 20 ------------- main.c | 17 +++++++++++ main.h | 6 ++++ tests/CMakeLists.txt | 24 ++++++++++++++++ tests/test_tree.c | 28 ++++++++++++++++++ 8 files changed, 203 insertions(+), 20 deletions(-) create mode 100644 cmake_modules/FindCheck.cmake create mode 100644 cmake_modules/FindJudy.cmake create mode 100644 cmake_modules/FindPCRE.cmake delete mode 100644 configure.ac create mode 100644 main.c create mode 100644 main.h create mode 100644 tests/CMakeLists.txt create mode 100644 tests/test_tree.c diff --git a/cmake_modules/FindCheck.cmake b/cmake_modules/FindCheck.cmake new file mode 100644 index 0000000..8edcc91 --- /dev/null +++ b/cmake_modules/FindCheck.cmake @@ -0,0 +1,54 @@ +# - Try to find the CHECK libraries +# Once done this will define +# +# CHECK_FOUND - system has check +# CHECK_INCLUDE_DIRS - the check include directory +# CHECK_LIBRARIES - check library +# +# Copyright (c) 2007 Daniel Gollub +# Copyright (c) 2007-2009 Bjoern Ricks +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + + +INCLUDE( FindPkgConfig ) + +IF ( Check_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "REQUIRED" ) +ELSE( Check_FIND_REQUIRED ) + SET( _pkgconfig_REQUIRED "" ) +ENDIF ( Check_FIND_REQUIRED ) + +IF ( CHECK_MIN_VERSION ) + PKG_SEARCH_MODULE( CHECK ${_pkgconfig_REQUIRED} check>=${CHECK_MIN_VERSION} ) +ELSE ( CHECK_MIN_VERSION ) + PKG_SEARCH_MODULE( CHECK ${_pkgconfig_REQUIRED} check ) +ENDIF ( CHECK_MIN_VERSION ) + +# Look for CHECK include dir and libraries +IF( NOT CHECK_FOUND AND NOT PKG_CONFIG_FOUND ) + + FIND_PATH( CHECK_INCLUDE_DIRS check.h ) + + FIND_LIBRARY( CHECK_LIBRARIES NAMES check ) + + IF ( CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES ) + SET( CHECK_FOUND 1 ) + IF ( NOT Check_FIND_QUIETLY ) + MESSAGE ( STATUS "Found CHECK: ${CHECK_LIBRARIES}" ) + ENDIF ( NOT Check_FIND_QUIETLY ) + ELSE ( CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES ) + IF ( Check_FIND_REQUIRED ) + MESSAGE( FATAL_ERROR "Could NOT find CHECK" ) + ELSE ( Check_FIND_REQUIRED ) + IF ( NOT Check_FIND_QUIETLY ) + MESSAGE( STATUS "Could NOT find CHECK" ) + ENDIF ( NOT Check_FIND_QUIETLY ) + ENDIF ( Check_FIND_REQUIRED ) + ENDIF ( CHECK_INCLUDE_DIRS AND CHECK_LIBRARIES ) +ENDIF( NOT CHECK_FOUND AND NOT PKG_CONFIG_FOUND ) + +# Hide advanced variables from CMake GUIs +MARK_AS_ADVANCED( CHECK_INCLUDE_DIRS CHECK_LIBRARIES ) diff --git a/cmake_modules/FindJudy.cmake b/cmake_modules/FindJudy.cmake new file mode 100644 index 0000000..1be69e1 --- /dev/null +++ b/cmake_modules/FindJudy.cmake @@ -0,0 +1,37 @@ +# Copyright (C) 2007-2009 LuaDist. +# Created by Peter Kapec +# Redistribution and use of this file is allowed according to the terms of the MIT license. +# For details see the COPYRIGHT file distributed with LuaDist. +# Note: +# Searching headers and libraries is very simple and is NOT as powerful as scripts +# distributed with CMake, because LuaDist defines directories to search for. +# Everyone is encouraged to contact the author with improvements. Maybe this file +# becomes part of CMake distribution sometimes. + +# - Find judy +# Find the native Judy headers and libraries. +# +# Judy_INCLUDE_DIRS - where to find judy.h, etc. +# Judy_LIBRARIES - List of libraries when using judy. +# Judy_FOUND - True if judy found. + +# Look for the header file. +FIND_PATH(Judy_INCLUDE_DIR NAMES Judy.h) + +# Look for the library. +FIND_LIBRARY(Judy_LIBRARY NAMES judy) + +# Handle the QUIETLY and REQUIRED arguments and set Judy_FOUND to TRUE if all listed variables are TRUE. +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(Judy DEFAULT_MSG Judy_LIBRARY Judy_INCLUDE_DIR) + +# Copy the results to the output variables. +IF(Judy_FOUND) + SET(Judy_LIBRARIES ${Judy_LIBRARY}) + SET(Judy_INCLUDE_DIRS ${Judy_INCLUDE_DIR}) +ELSE(Judy_FOUND) + SET(Judy_LIBRARIES) + SET(Judy_INCLUDE_DIRS) +ENDIF(Judy_FOUND) + +MARK_AS_ADVANCED(Judy_INCLUDE_DIRS Judy_LIBRARIES) diff --git a/cmake_modules/FindPCRE.cmake b/cmake_modules/FindPCRE.cmake new file mode 100644 index 0000000..dbbd60a --- /dev/null +++ b/cmake_modules/FindPCRE.cmake @@ -0,0 +1,37 @@ +# Copyright (C) 2007-2009 LuaDist. +# Created by Peter Kapec +# Redistribution and use of this file is allowed according to the terms of the MIT license. +# For details see the COPYRIGHT file distributed with LuaDist. +# Note: +# Searching headers and libraries is very simple and is NOT as powerful as scripts +# distributed with CMake, because LuaDist defines directories to search for. +# Everyone is encouraged to contact the author with improvements. Maybe this file +# becomes part of CMake distribution sometimes. + +# - Find pcre +# Find the native PCRE headers and libraries. +# +# PCRE_INCLUDE_DIRS - where to find pcre.h, etc. +# PCRE_LIBRARIES - List of libraries when using pcre. +# PCRE_FOUND - True if pcre found. + +# Look for the header file. +FIND_PATH(PCRE_INCLUDE_DIR NAMES pcre.h) + +# Look for the library. +FIND_LIBRARY(PCRE_LIBRARY NAMES pcre) + +# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE. +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_INCLUDE_DIR) + +# Copy the results to the output variables. +IF(PCRE_FOUND) + SET(PCRE_LIBRARIES ${PCRE_LIBRARY}) + SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR}) +ELSE(PCRE_FOUND) + SET(PCRE_LIBRARIES) + SET(PCRE_INCLUDE_DIRS) +ENDIF(PCRE_FOUND) + +MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES) diff --git a/configure.ac b/configure.ac deleted file mode 100644 index a80fd30..0000000 --- a/configure.ac +++ /dev/null @@ -1,20 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ([2.69]) -AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS]) -AC_CONFIG_SRCDIR([config.h.in]) -AC_CONFIG_HEADERS([config.h]) - -# Checks for programs. -AC_PROG_CC - -# Checks for libraries. - -# Checks for header files. - -# Checks for typedefs, structures, and compiler characteristics. - -# Checks for library functions. - -AC_OUTPUT diff --git a/main.c b/main.c new file mode 100644 index 0000000..f3c4d1a --- /dev/null +++ b/main.c @@ -0,0 +1,17 @@ + +#include +#include +#include "main.h" + +typedef struct _Node { + char ** patterns; +} Node; + + + + + + +void compile() { + +} diff --git a/main.h b/main.h new file mode 100644 index 0000000..591a73d --- /dev/null +++ b/main.h @@ -0,0 +1,6 @@ +#ifndef MAIN_H +#define MAIN_H + +void compile(); + +#endif diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..d09a52a --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,24 @@ +# set(TEST_LIBS ${TEST_LIBS} ${CHECK_LIBRARIES} judy libr2) +# set(TEST_LIBS ${TEST_LIBS} ${CHECK_LIBRARIES} judy libr2) +find_package(Check REQUIRED) +find_package(PCRE REQUIRED) +find_package(Judy REQUIRED) + +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} ${Judy_LIBRARIES} libr2) + + include_directories(${CHECK_INCLUDE_DIRS}) + # include_directories("${PROJECT_SOURCE_DIR}/include/r2") + add_executable(test_tree test_tree.c) + target_link_libraries(test_tree ${TEST_LIBS}) + + add_custom_command( + TARGET test_tree POST_BUILD + COMMENT "Running unit tests" + COMMAND test_tree + ) +endif (NOT CHECK_FOUND) + + diff --git a/tests/test_tree.c b/tests/test_tree.c new file mode 100644 index 0000000..506f748 --- /dev/null +++ b/tests/test_tree.c @@ -0,0 +1,28 @@ +#include +#include + +START_TEST (test_tree) +{ +} +END_TEST + + +Suite* str_suite (void) { + Suite *suite = suite_create("test_tree"); + /* + TCase *tcase = tcase_create("case"); + tcase_add_test(tcase, test_tree); + suite_add_tcase(suite, tcase); + */ + return suite; +} + +int main (int argc, char *argv[]) { + int number_failed; + Suite *suite = str_suite(); + SRunner *runner = srunner_create(suite); + srunner_run_all(runner, CK_NORMAL); + number_failed = srunner_ntests_failed(runner); + srunner_free(runner); + return number_failed; +}