mirror of https://github.com/getdnsapi/getdns.git
Add check for check library, and if found add the main test module.
Note that tests_dict/list/stub_async/namespaces are built, but not run. I don't know why.
This commit is contained in:
parent
24e2d1acbf
commit
d447999c60
|
@ -4,6 +4,8 @@ if (POLICY CMP0075)
|
||||||
cmake_policy(SET CMP0075 NEW)
|
cmake_policy(SET CMP0075 NEW)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")
|
||||||
|
|
||||||
set(CMAKE_VERBOSE_MAKEFILE_ON)
|
set(CMAKE_VERBOSE_MAKEFILE_ON)
|
||||||
|
|
||||||
# The following must be set BEFORE doing project() or enable_language().
|
# The following must be set BEFORE doing project() or enable_language().
|
||||||
|
@ -546,6 +548,57 @@ target_link_libraries(getdns_server_mon
|
||||||
)
|
)
|
||||||
set_property(TARGET getdns_server_mon PROPERTY C_STANDARD 11)
|
set_property(TARGET getdns_server_mon PROPERTY C_STANDARD 11)
|
||||||
|
|
||||||
|
find_package(Check "0.9.6")
|
||||||
|
|
||||||
|
if (NOT Check_FOUND)
|
||||||
|
message(WARNING "check library not found, not building test programs")
|
||||||
|
else ()
|
||||||
|
add_executable(check_getdns
|
||||||
|
src/test/check_getdns_common.c
|
||||||
|
src/test/check_getdns_context_set_timeout.c
|
||||||
|
src/test/check_getdns_transport.c
|
||||||
|
src/test/check_getdns_selectloop.c
|
||||||
|
src/test/check_getdns.c
|
||||||
|
)
|
||||||
|
target_link_libraries(check_getdns
|
||||||
|
PRIVATE
|
||||||
|
getdns
|
||||||
|
Check::Check
|
||||||
|
Threads::Threads
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(tests_dict
|
||||||
|
src/test/tests_dict.c
|
||||||
|
src/test/testmessages.c
|
||||||
|
)
|
||||||
|
target_link_libraries(tests_dict PRIVATE getdns Check::Check)
|
||||||
|
|
||||||
|
add_executable(tests_list
|
||||||
|
src/test/tests_list.c
|
||||||
|
src/test/testmessages.c
|
||||||
|
)
|
||||||
|
target_link_libraries(tests_list PRIVATE getdns Check::Check)
|
||||||
|
|
||||||
|
add_executable(tests_namespaces src/test/tests_namespaces.c)
|
||||||
|
target_link_libraries(tests_namespaces PRIVATE getdns Check::Check)
|
||||||
|
|
||||||
|
add_executable(tests_stub_async
|
||||||
|
src/test/tests_stub_async.c
|
||||||
|
src/test/testmessages.c
|
||||||
|
)
|
||||||
|
target_link_libraries(tests_stub_async PRIVATE getdns Check::Check)
|
||||||
|
|
||||||
|
add_executable(tests_stub_sync src/test/tests_stub_sync.c)
|
||||||
|
target_link_libraries(tests_stub_sync PRIVATE getdns Check::Check)
|
||||||
|
|
||||||
|
include(CTest)
|
||||||
|
|
||||||
|
add_test(NAME test_noeventloop COMMAND check_getdns)
|
||||||
|
set_property(TEST test_noeventloop PROPERTY
|
||||||
|
ENVIRONMENT "GETDNS_TEST_PORT=43210;CK_TIMEOUT_MULTIPLIER=2;CK_LOG_FILE_NAME=check_getdns.log"
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
# Substitutions in files.
|
# Substitutions in files.
|
||||||
configure_file(cmake/include/cmakeconfig.h.in config.h)
|
configure_file(cmake/include/cmakeconfig.h.in config.h)
|
||||||
configure_file(src/getdns/getdns.h.in getdns/getdns.h)
|
configure_file(src/getdns/getdns.h.in getdns/getdns.h)
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||||
|
|
||||||
|
#[=======================================================================[.rst:
|
||||||
|
FindCheck
|
||||||
|
--------
|
||||||
|
|
||||||
|
Find the Check (Unit Testing Framework for C) library
|
||||||
|
|
||||||
|
Imported targets
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
This module defines the following :prop_tgt:`IMPORTED` targets:
|
||||||
|
|
||||||
|
``Check::Check``
|
||||||
|
The Check library, if found.
|
||||||
|
|
||||||
|
Result variables
|
||||||
|
^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
This module will set the following variables in your project:
|
||||||
|
|
||||||
|
``Check_FOUND``
|
||||||
|
If false, do not try to use Check.
|
||||||
|
``CHECK_INCLUDE_DIR``
|
||||||
|
where to find check.h, etc.
|
||||||
|
``CHECK_LIBRARIES``
|
||||||
|
the libraries needed to use Check.
|
||||||
|
``CHECK_VERSION``
|
||||||
|
the version of the Check library found
|
||||||
|
|
||||||
|
#]=======================================================================]
|
||||||
|
|
||||||
|
find_path(CHECK_INCLUDE_DIR check.h
|
||||||
|
HINTS
|
||||||
|
${PC_CHECK_INCLUDEDIR}
|
||||||
|
${PC_CHECK_INCLUDE_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Check for PIC and non-PIC libraries. If PIC present, use that
|
||||||
|
# in preference (as per Debian check.pc).
|
||||||
|
find_library(CHECK_LIBRARY NAMES check_pic libcheck_pic
|
||||||
|
HINTS
|
||||||
|
${PC_CHECK_LIBDIR}
|
||||||
|
${PC_CHECK_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOT CHECK_LIBRARY)
|
||||||
|
find_library(CHECK_LIBRARY NAMES check libcheck
|
||||||
|
HINTS
|
||||||
|
${PC_CHECK_LIBDIR}
|
||||||
|
${PC_CHECK_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(CHECK_LIBRARIES "")
|
||||||
|
|
||||||
|
# Check may need the math, subunit and rt libraries on Unix
|
||||||
|
if (UNIX)
|
||||||
|
find_library(CHECK_MATH_LIBRARY m)
|
||||||
|
find_library(CHECK_RT_LIBRARY rt)
|
||||||
|
find_library(CHECK_SUBUNIT_LIBRARY subunit)
|
||||||
|
|
||||||
|
if (CHECK_MATH_LIBRARY)
|
||||||
|
list(APPEND CHECK_LIBRARIES "${CHECK_MATH_LIBRARY}")
|
||||||
|
endif ()
|
||||||
|
if (CHECK_RT_LIBRARY)
|
||||||
|
list(APPEND CHECK_LIBRARIES "${CHECK_RT_LIBRARY}")
|
||||||
|
endif ()
|
||||||
|
if (CHECK_SUBUNIT_LIBRARY)
|
||||||
|
list(APPEND CHECK_LIBRARIES "${CHECK_SUBUNIT_LIBRARY}")
|
||||||
|
endif ()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (CHECK_INCLUDE_DIR AND CHECK_LIBRARY)
|
||||||
|
if (NOT TARGET Check::Check)
|
||||||
|
add_library(Check::Check UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(Check::Check PROPERTIES
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES "${CHECK_INCLUDE_DIR}"
|
||||||
|
INTERFACE_LINK_LIBRARIES "${CHECK_LIBRARIES}"
|
||||||
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
|
IMPORTED_LOCATION "${CHECK_LIBRARY}"
|
||||||
|
)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
if (NOT CHECK_VERSION AND CHECK_INCLUDE_DIR AND EXISTS "${CHECK_INCLUDE_DIR}/check.h")
|
||||||
|
file(STRINGS "${CHECK_INCLUDE_DIR}/check.h" CHECK_H REGEX "^#define CHECK_M[A-Z]+_VERSION")
|
||||||
|
string(REGEX REPLACE "^.*\(([0-9]+)\).*\(([0-9]+)\).*\(([0-9]+)\).*$" "\\1.\\2.\\3" CHECK_VERSION "${CHECK_H}")
|
||||||
|
endif ()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND CHECK_LIBRARIES "${CHECK_LIBRARY}")
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(Check
|
||||||
|
REQUIRED_VARS CHECK_LIBRARIES CHECK_INCLUDE_DIR
|
||||||
|
VERSION_VAR CHECK_VERSION
|
||||||
|
)
|
||||||
|
|
||||||
|
mark_as_advanced(CHECK_INCLUDE_DIR CHECK_LIBRARIES)
|
Loading…
Reference in New Issue