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

120 lines
3.0KB

  1. project(
  2. 'jsoncpp',
  3. 'cpp',
  4. # Note: version must be updated in three places when doing a release. This
  5. # annoying process ensures that amalgamate, CMake, and meson all report the
  6. # correct version.
  7. # 1. /meson.build
  8. # 2. /include/json/version.h
  9. # 3. /CMakeLists.txt
  10. # IMPORTANT: also update the SOVERSION!!
  11. version : '1.9.4',
  12. default_options : [
  13. 'buildtype=release',
  14. 'cpp_std=c++11',
  15. 'warning_level=1'],
  16. license : 'Public Domain',
  17. meson_version : '>= 0.49.0')
  18. jsoncpp_headers = files([
  19. 'include/json/allocator.h',
  20. 'include/json/assertions.h',
  21. 'include/json/config.h',
  22. 'include/json/json_features.h',
  23. 'include/json/forwards.h',
  24. 'include/json/json.h',
  25. 'include/json/reader.h',
  26. 'include/json/value.h',
  27. 'include/json/version.h',
  28. 'include/json/writer.h',
  29. ])
  30. jsoncpp_include_directories = include_directories('include')
  31. install_headers(
  32. jsoncpp_headers,
  33. subdir : 'json')
  34. if get_option('default_library') == 'shared' and meson.get_compiler('cpp').get_id() == 'msvc'
  35. dll_export_flag = '-DJSON_DLL_BUILD'
  36. dll_import_flag = '-DJSON_DLL'
  37. else
  38. dll_export_flag = []
  39. dll_import_flag = []
  40. endif
  41. jsoncpp_lib = library(
  42. 'jsoncpp', files([
  43. 'src/lib_json/json_reader.cpp',
  44. 'src/lib_json/json_value.cpp',
  45. 'src/lib_json/json_writer.cpp',
  46. ]),
  47. soversion : 25,
  48. install : true,
  49. include_directories : jsoncpp_include_directories,
  50. cpp_args: dll_export_flag)
  51. import('pkgconfig').generate(
  52. libraries : jsoncpp_lib,
  53. version : meson.project_version(),
  54. name : 'jsoncpp',
  55. filebase : 'jsoncpp',
  56. description : 'A C++ library for interacting with JSON')
  57. # for libraries bundling jsoncpp
  58. jsoncpp_dep = declare_dependency(
  59. include_directories : jsoncpp_include_directories,
  60. link_with : jsoncpp_lib,
  61. version : meson.project_version())
  62. # tests
  63. if meson.is_subproject() or not get_option('tests')
  64. subdir_done()
  65. endif
  66. python = import('python').find_installation()
  67. jsoncpp_test = executable(
  68. 'jsoncpp_test', files([
  69. 'src/test_lib_json/jsontest.cpp',
  70. 'src/test_lib_json/main.cpp',
  71. 'src/test_lib_json/fuzz.cpp',
  72. ]),
  73. include_directories : jsoncpp_include_directories,
  74. link_with : jsoncpp_lib,
  75. install : false,
  76. cpp_args: dll_import_flag)
  77. test(
  78. 'unittest_jsoncpp_test',
  79. jsoncpp_test)
  80. jsontestrunner = executable(
  81. 'jsontestrunner',
  82. 'src/jsontestrunner/main.cpp',
  83. include_directories : jsoncpp_include_directories,
  84. link_with : jsoncpp_lib,
  85. install : false,
  86. cpp_args: dll_import_flag)
  87. test(
  88. 'unittest_jsontestrunner',
  89. python,
  90. args : [
  91. '-B',
  92. join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
  93. jsontestrunner,
  94. join_paths(meson.current_source_dir(), 'test/data')],
  95. )
  96. test(
  97. 'jsonchecker_jsontestrunner',
  98. python,
  99. is_parallel : false,
  100. args : [
  101. '-B',
  102. join_paths(meson.current_source_dir(), 'test/runjsontests.py'),
  103. '--with-json-checker',
  104. jsontestrunner,
  105. join_paths(meson.current_source_dir(), 'test/data')],
  106. workdir : join_paths(meson.current_source_dir(), 'test/data'),
  107. )