Commit b02c371e by Vicent Marti

Build the new test file with CMake too

Signed-off-by: Vicent Marti <tanoku@gmail.com>
parent 2a1732b4
...@@ -34,7 +34,6 @@ SET(INSTALL_INC include CACHE PATH "Where to install headers to.") ...@@ -34,7 +34,6 @@ SET(INSTALL_INC include CACHE PATH "Where to install headers to.")
# Build options # Build options
OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON) OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
OPTION (BUILD_TESTS "Build Tests" ON) OPTION (BUILD_TESTS "Build Tests" ON)
OPTION (BACKTRACE "Use GCC backtrace in tests (Not available on Cygwin/MinGW)" OFF)
# Build Release by default # Build Release by default
IF (NOT CMAKE_BUILD_TYPE) IF (NOT CMAKE_BUILD_TYPE)
...@@ -56,11 +55,6 @@ IF (WIN32 AND NOT CYGWIN) ...@@ -56,11 +55,6 @@ IF (WIN32 AND NOT CYGWIN)
ENDIF () ENDIF ()
ENDIF () ENDIF ()
# When desired build with backtrace
IF (BACKTRACE)
ADD_DEFINITIONS(-DBACKTRACE)
ENDIF ()
# Specify sha1 implementation # Specify sha1 implementation
IF (SHA1_TYPE STREQUAL "ppc") IF (SHA1_TYPE STREQUAL "ppc")
ADD_DEFINITIONS(-DPPC_SHA1) ADD_DEFINITIONS(-DPPC_SHA1)
...@@ -91,26 +85,12 @@ IF (BUILD_TESTS) ...@@ -91,26 +85,12 @@ IF (BUILD_TESTS)
ADD_DEFINITIONS(-DTEST_RESOURCES=\"${TEST_RESOURCES}\") ADD_DEFINITIONS(-DTEST_RESOURCES=\"${TEST_RESOURCES}\")
ENABLE_TESTING() ENABLE_TESTING()
# Find and build all tests
INCLUDE_DIRECTORIES(tests) INCLUDE_DIRECTORIES(tests)
FILE (GLOB TESTS tests/t????-*.c)
FILE(GLOB SRC_TEST tests/t??-*.c)
FOREACH (TEST_SRC ${TESTS})
# Match the source to get test name ADD_EXECUTABLE(libgit2_test tests/test_main.c tests/test_lib.c tests/test_helpers.c ${SRC} ${SRC_PLAT} ${SRC_SHA1} ${SRC_TEST})
STRING(REGEX MATCH "(t....-.*).c$" TEST_NAME ${TEST_SRC}) TARGET_LINK_LIBRARIES(libgit2_test ${ZLIB_LIBRARY} ${LIB_SHA1} ${PTHREAD_LIBRARY})
SET(TEST_NAME ${CMAKE_MATCH_1}) # This is the actual matched variable, got to love CMake macro language
ADD_TEST(libgit2_test libgit2_test)
# Generate TOC by finding BEGIN_TEST entries in test source.
FILE(READ ${TEST_SRC} TEST_CODE)
STRING(REGEX MATCHALL "BEGIN_TEST\\([^\\)]*\\)\n" TEST_TOC ${TEST_CODE})
FILE(WRITE tests/${TEST_NAME}.toc ${TEST_TOC}) # If desired this might be moved to the build dir
# Compile
ADD_EXECUTABLE(${TEST_NAME} tests/test_main.c tests/test_lib.c tests/test_helpers.c ${TEST_SRC})
TARGET_LINK_LIBRARIES(${TEST_NAME} git2)
SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES COMPILE_DEFINITIONS TEST_TOC=\"${TEST_NAME}.toc\")
# Add CTest
ADD_TEST(${TEST_NAME} ${TEST_NAME})
ENDFOREACH ()
ENDIF () ENDIF ()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment