1############################################
2#
3# How to build bsdtar_test
4#
5############################################
6IF(ENABLE_TAR AND ENABLE_TEST)
7  SET(bsdtar_test_SOURCES
8    ../getdate.c
9    main.c
10    test.h
11    test_0.c
12    test_basic.c
13    test_copy.c
14    test_empty_mtree.c
15    test_getdate.c
16    test_help.c
17    test_option_T_upper.c
18    test_option_q.c
19    test_option_r.c
20    test_option_s.c
21    test_patterns.c
22    test_stdio.c
23    test_strip_components.c
24    test_symlink_dir.c
25    test_version.c
26    test_windows.c
27  )
28  IF(WIN32 AND NOT CYGWIN)
29    LIST(APPEND bsdtar_test_SOURCES ../bsdtar_windows.c)
30    LIST(APPEND bsdtar_test_SOURCES ../bsdtar_windows.h)
31  ENDIF(WIN32 AND NOT CYGWIN)
32
33  #
34  # Register target
35  #
36  ADD_EXECUTABLE(bsdtar_test ${bsdtar_test_SOURCES})
37  SET_PROPERTY(TARGET bsdtar_test PROPERTY COMPILE_DEFINITIONS LIST_H)
38
39  #
40  # Generate list.h by grepping DEFINE_TEST() lines out of the C sources.
41  #
42  GENERATE_LIST_H(${CMAKE_CURRENT_BINARY_DIR}/list.h
43    ${CMAKE_CURRENT_LIST_FILE} ${bsdtar_test_SOURCES})
44  SET_PROPERTY(DIRECTORY APPEND PROPERTY INCLUDE_DIRECTORIES
45    ${CMAKE_CURRENT_BINARY_DIR})
46
47  # list.h has a line DEFINE_TEST(testname) for every
48  # test.  We can use that to define the tests for cmake by
49  # defining a DEFINE_TEST macro and reading list.h in.
50  MACRO (DEFINE_TEST _testname)
51    ADD_TEST_28(
52      NAME bsdtar_${_testname}
53      COMMAND bsdtar_test -vv
54                          -p $<TARGET_FILE:bsdtar>
55                          -r ${CMAKE_CURRENT_SOURCE_DIR}
56                          ${_testname})
57  ENDMACRO (DEFINE_TEST _testname)
58
59  INCLUDE(${CMAKE_CURRENT_BINARY_DIR}/list.h)
60
61  # Experimental new test handling
62  ADD_CUSTOM_TARGET(run_bsdtar_test
63	COMMAND	bsdtar_test -p ${BSDTAR} -r ${CMAKE_CURRENT_SOURCE_DIR})
64  ADD_DEPENDENCIES(run_bsdtar_test bsdtar)
65  ADD_DEPENDENCIES(run_all_tests run_bsdtar_test)
66
67ENDIF (ENABLE_TAR AND ENABLE_TEST)
68