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) find_package(CUnit 2.1)
enable_testing() enable_testing()
set(HAVE_CUNIT ${CUNIT_FOUND}) set(HAVE_CUNIT ${CUNIT_FOUND})
if(HAVE_CUNIT)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND})
endif()
# openssl (for src) # openssl (for src)
set(HAVE_OPENSSL ${OPENSSL_FOUND}) set(HAVE_OPENSSL ${OPENSSL_FOUND})
@ -357,11 +360,6 @@ if(NOT ENABLE_THREADS OR NOT HAVE_STD_FUTURE)
set(NOTHREADS 1) set(NOTHREADS 1)
endif() 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) add_definitions(-DHAVE_CONFIG_H)
configure_file(cmakeconfig.h.in config.h) configure_file(cmakeconfig.h.in config.h)
# autotools-compatible names # autotools-compatible names

View File

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

View File

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