meson.build 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.3',
  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 : 23,
  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('python3')
  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. )