meson.build 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. if get_option('enable_cjson_tests')
  2. unity_flags = []
  3. if (compiler.get_id() == 'clang') or (compiler.get_id() == 'gcc')
  4. unity_flags += [
  5. '-Wno-switch-enum',
  6. '-Wno-error',
  7. '-fvisibility=default',
  8. '-fno-sanitize=float-divide-by-zero'
  9. ]
  10. endif
  11. unity_c_args = []
  12. foreach flag : unity_flags
  13. if compiler.has_argument(flag)
  14. unity_c_args += flag
  15. endif
  16. endforeach
  17. unity = library('unity', 'unity/src/unity.c', c_args: unity_c_args)
  18. common = library('test_common', 'common.c')
  19. cjson_tests = [
  20. 'parse_examples',
  21. 'parse_number',
  22. 'parse_hex4',
  23. 'parse_string',
  24. 'parse_array',
  25. 'parse_object',
  26. 'parse_value',
  27. 'print_string',
  28. 'print_number',
  29. 'print_array',
  30. 'print_object',
  31. 'print_value',
  32. 'misc_tests',
  33. 'parse_with_opts',
  34. 'compare_tests'
  35. ]
  36. foreach cjson_test : cjson_tests
  37. exe = executable(cjson_test, cjson_test + '.c', link_with: [common, cjson, unity])
  38. test(cjson_test, exe, workdir: meson.current_source_dir())
  39. endforeach
  40. if get_option('enable_cjson_utils')
  41. cjson_utils_tests = [
  42. 'json_patch_tests',
  43. 'old_utils_tests',
  44. 'misc_utils_tests'
  45. ]
  46. foreach cjson_utils_test : cjson_utils_tests
  47. exe = executable(cjson_utils_test, cjson_utils_test + '.c', link_with: [common, cjson_utils, unity, cjson])
  48. test(cjson_utils_test, exe, workdir: meson.current_source_dir())
  49. endforeach
  50. endif
  51. endif