-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
62 lines (52 loc) · 1.59 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
enable_testing()
add_library(unity STATIC unity/src/unity.c)
set(
unity_testcases
test_literal
test_range
test_sequence
test_choice
test_reference
test_positive
test_negative
test_repeat
test_flags
test_back_reference
test_misc
test_example_mustache
test_example_json
)
option(ENABLE_VALGRIND "Enable vagrind memory leak report." OFF)
if (ENABLE_VALGRIND)
find_program(VALGRIND valgrind)
message("-- Valgrind found: ${VALGRIND}")
if (VALGRIND)
set(VALGRIND_OPTIONS --trace-children=yes --leak-check=full --show-leak-kinds=all --error-exitcode=1)
else()
message(WARNING "Valgrind not installed.")
unset(VALGRIND)
endif()
endif()
foreach(unity_testcase ${unity_testcases})
add_executable("${unity_testcase}" "${unity_testcase}.c" "unity_setup.c")
target_link_libraries("${unity_testcase}" "${P4_LIB}" unity)
target_compile_options("${unity_testcase}" PRIVATE "-g")
target_compile_options("${unity_testcase}" PRIVATE "-ansi")
if (VALGRIND)
add_test(
NAME "${unity_testcase}"
COMMAND "${VALGRIND}" ${VALGRIND_OPTIONS} "${CMAKE_CURRENT_BINARY_DIR}/${unity_testcase}"
)
else()
add_test(
NAME "${unity_testcase}"
COMMAND "./${unity_testcase}"
)
endif()
endforeach()
add_custom_target(
check
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/json_test_parsing ${CMAKE_CURRENT_BINARY_DIR}/json_test_parsing
COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure
DEPENDS ${unity_testcases}
)