meson.build 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. project('cJSON', 'c', default_options: ['c_std=c89'])
  2. version = '1.6.0'
  3. soversion = '0'
  4. compiler = meson.get_compiler('c')
  5. compiler_flags = []
  6. if (compiler.get_id() == 'clang') or (compiler.get_id() == 'gcc')
  7. compiler_flags += [
  8. '-pedantic',
  9. '-Wall',
  10. '-Wextra',
  11. '-Werror',
  12. '-Wstrict-prototypes',
  13. '-Wwrite-strings',
  14. '-Wshadow',
  15. '-Winit-self',
  16. '-Wcast-align',
  17. '-Wformat=2',
  18. '-Wmissing-prototypes',
  19. '-Wstrict-overflow=2',
  20. '-Wcast-qual',
  21. '-Wundef',
  22. '-Wswitch-default',
  23. '-Wconversion',
  24. '-Wc++-compat',
  25. '-fstack-protector-strong',
  26. '-Wcomma',
  27. '-Wdouble-promotion',
  28. '-Wparentheses',
  29. '-Wformat-overflow',
  30. '-Wunused-macros',
  31. '-Wmissing-variable-declarations',
  32. '-Wused-but-marked-unused',
  33. '-Wswitch-enum'
  34. ]
  35. endif
  36. foreach flag : compiler_flags
  37. if compiler.has_argument(flag)
  38. add_project_arguments(flag, language: 'c')
  39. endif
  40. endforeach
  41. math = compiler.find_library('m', required: false)
  42. cjson = shared_library('cjson', 'cJSON.c', dependencies: math, version: version, soversion: soversion, install: true)
  43. if get_option('enable_cjson_utils')
  44. cjson_utils = shared_library('cjson_utils', 'cJSON_Utils.c', link_with: cjson, version: version, soversion: soversion, install: true)
  45. endif
  46. if get_option('enable_cjson_tests')
  47. cjson_test = executable('cjson_test', 'test.c', link_with: cjson)
  48. test('cjson_test', cjson_test)
  49. endif
  50. subdir('tests')