cmake: add "check" target

Add a "check" target that builds tests before running them.
This commit is contained in:
Peter Wu 2016-03-12 00:57:30 +01:00
parent 2c525f2471
commit 618073e2b4
3 changed files with 6 additions and 5 deletions

View File

@ -170,6 +170,9 @@ endif()
find_package(CUnit 2.1)
enable_testing()
set(HAVE_CUNIT ${CUNIT_FOUND})
if(HAVE_CUNIT)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
endif()
# openssl (for src)
set(HAVE_OPENSSL ${OPENSSL_FOUND})
@ -357,11 +360,6 @@ if(NOT ENABLE_THREADS OR NOT HAVE_STD_FUTURE)
set(NOTHREADS 1)
endif()
# # propagate $enable_static to tests/Makefile.am
# AM_CONDITIONAL([ENABLE_STATIC], [test "x$enable_static" = "xyes"])
#
# AC_SUBST([APPLDFLAGS])
add_definitions(-DHAVE_CONFIG_H)
configure_file(cmakeconfig.h.in config.h)
# autotools-compatible names

View File

@ -173,6 +173,7 @@ if(ENABLE_APP)
endif()
add_test(nghttpx-unittest nghttpx-unittest)
add_dependencies(check nghttpx-unittest)
endif()
add_executable(nghttp ${NGHTTP_SOURCES} $<TARGET_OBJECTS:http-parser>)

View File

@ -33,6 +33,7 @@ if(HAVE_CUNIT)
${CUNIT_LIBRARIES}
)
add_test(main main)
add_dependencies(check main)
if(ENABLE_FAILMALLOC)
set(FAILMALLOC_SOURCES
@ -48,6 +49,7 @@ if(HAVE_CUNIT)
${CUNIT_LIBRARIES}
)
add_test(failmalloc failmalloc)
add_dependencies(check failmalloc)
endif()
if(ENABLE_APP)