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.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. foreach(TESTNAME
  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. add_executable(${TESTNAME} ${TESTNAME}.c)
  35. if(${TESTNAME} STREQUAL test_strerror OR ${TESTNAME} STREQUAL test_util_file)
  36. # For output consistency, we need _json_c_strerror() in some tests:
  37. target_sources(${TESTNAME} PRIVATE ../strerror_override.c)
  38. endif()
  39. add_test(NAME ${TESTNAME} COMMAND ${PROJECT_SOURCE_DIR}/tests/${TESTNAME}.test)
  40. # XXX using the non-target_ versions of these doesn't work :(
  41. target_include_directories(
  42. ${TESTNAME}
  43. PUBLIC
  44. ${CMAKE_CURRENT_LIST_DIR}
  45. )
  46. target_link_libraries(
  47. ${TESTNAME}
  48. PRIVATE
  49. ${PROJECT_NAME}
  50. )
  51. endforeach(TESTNAME)