Imported Upstream version 0.15
[platform/upstream/json-c.git] / tests / CMakeLists.txt
1
2 add_executable(test1Formatted test1.c parse_flags.c parse_flags.h)
3 target_compile_definitions(test1Formatted PRIVATE TEST_FORMATTED=1)
4 target_link_libraries(test1Formatted PRIVATE ${PROJECT_NAME})
5
6 add_executable(test2Formatted test2.c parse_flags.c parse_flags.h)
7 target_compile_definitions(test2Formatted PRIVATE TEST_FORMATTED=1)
8 target_link_libraries(test2Formatted PRIVATE ${PROJECT_NAME})
9
10 # https://cmake.org/cmake/help/v3.0/command/add_test.html
11 # https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/
12
13 include_directories(PUBLIC ${CMAKE_SOURCE_DIR})
14
15 foreach(TESTNAME
16         test1
17         test2
18         test4
19         testReplaceExisting
20         test_cast
21         test_charcase
22         test_compare
23         test_deep_copy
24         test_double_serializer
25         test_float
26         test_int_add
27         test_json_pointer
28         test_locale
29         test_null
30         test_parse
31         test_parse_int64
32         test_printbuf
33         test_set_serializer
34         test_set_value
35         test_util_file
36         test_visit
37         test_object_iterator)
38
39 add_executable(${TESTNAME} ${TESTNAME}.c)
40 if(${TESTNAME} STREQUAL test_util_file)
41 # For output consistency, we need _json_c_strerror() in some tests:
42 target_sources(${TESTNAME} PRIVATE ../strerror_override.c)
43 endif()
44 add_test(NAME ${TESTNAME} COMMAND ${PROJECT_SOURCE_DIR}/tests/${TESTNAME}.test)
45
46 # XXX using the non-target_ versions of these doesn't work :(
47 target_include_directories(
48   ${TESTNAME}
49   PUBLIC
50     ${CMAKE_CURRENT_LIST_DIR}
51   )
52 target_link_libraries(
53   ${TESTNAME}
54   PRIVATE
55     ${PROJECT_NAME}
56   )
57
58 endforeach(TESTNAME)