You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

CMakeLists.txt 1.6 kB

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