Blame view

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