summaryrefslogtreecommitdiff
blob: 7ff132eaa591e3ea878693b5d5c6a3fce7ab5d20 (plain)
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
https://github.com/google/mozc/issues/490

--- /src/gyp/defines.gypi
+++ /src/gyp/defines.gypi
@@ -71,6 +71,10 @@
     # use_system_gtest represents if system version or bundled version
     # of gtest library is used.
     'use_system_gtest%': '0',
+
+    # use_system_jsoncpp represents if system version or bundled version
+    # of jsoncpp library is used.
+    'use_system_jsoncpp%': '0',
   },
   'target_defaults': {
     'defines': [
--- /src/net/jsoncpp.gyp
+++ /src/net/jsoncpp.gyp
@@ -31,32 +31,60 @@
   'targets': [
     {
       'target_name': 'jsoncpp',
-      'type': 'static_library',
-      'variables': {
-        'jsoncpp_root': '<(third_party_dir)/jsoncpp',
-        'jsoncpp_srcs': [
-          '<(jsoncpp_root)/src/lib_json/json_reader.cpp',
-          '<(jsoncpp_root)/src/lib_json/json_value.cpp',
-          '<(jsoncpp_root)/src/lib_json/json_writer.cpp',
-        ],
-        'jsoncpp_include_dirs': ['<(jsoncpp_root)/include'],
-        'jsoncpp_additional_macros': ['JSON_USE_EXCEPTION=0'],
-      },
-      'defines': [
-        '<@(jsoncpp_additional_macros)',
+      'conditions': [
+        ['use_system_jsoncpp==1', {
+          'type': 'none',
+          'variables': {
+            'jsoncpp_additional_macros': [
+              'JSON_USE_EXCEPTION=0',
+              'MOZC_USE_SYSTEM_JSONCPP',
+            ],
+          },
+          'all_dependent_settings': {
+            'defines': [
+              '<@(jsoncpp_additional_macros)',
+            ],
+            'cflags': [
+              '<!@(pkg-config --cflags jsoncpp)',
+            ],
+            'link_settings': {
+              'libraries': [
+                '<!@(pkg-config --libs-only-l jsoncpp)',
+              ],
+              'ldflags': [
+                '<!@(pkg-config --libs-only-L jsoncpp)',
+              ],
+            }
+          },
+        }, {
+          'type': 'static_library',
+          'variables': {
+            'jsoncpp_root': '<(third_party_dir)/jsoncpp',
+            'jsoncpp_srcs': [
+              '<(jsoncpp_root)/src/lib_json/json_reader.cpp',
+              '<(jsoncpp_root)/src/lib_json/json_value.cpp',
+              '<(jsoncpp_root)/src/lib_json/json_writer.cpp',
+            ],
+            'jsoncpp_include_dirs': ['<(jsoncpp_root)/include'],
+            'jsoncpp_additional_macros': ['JSON_USE_EXCEPTION=0'],
+          },
+          'defines': [
+            '<@(jsoncpp_additional_macros)',
+          ],
+          'sources': [
+            '<@(jsoncpp_srcs)',
+            'jsoncpp.h',
+          ],
+          'include_dirs': [
+            '<@(jsoncpp_include_dirs)',
+          ],
+          'all_dependent_settings': {
+            'defines': [
+              '<@(jsoncpp_additional_macros)',
+            ],
+          },
+        }],
       ],
-      'sources': [
-        '<@(jsoncpp_srcs)',
-        'jsoncpp.h',
-      ],
-      'include_dirs': [
-        '<@(jsoncpp_include_dirs)',
-      ],
-      'all_dependent_settings': {
-        'defines': [
-          '<@(jsoncpp_additional_macros)',
-        ],
-      },
     },
   ],
 }
--- /src/net/jsoncpp.h
+++ /src/net/jsoncpp.h
@@ -35,7 +35,11 @@
 // Mozc basically disables C++ exception.
 #define JSON_USE_EXCEPTION 0
 #endif  // !JSON_USE_EXCEPTION
+#ifdef MOZC_USE_SYSTEM_JSONCPP
+#include <json/json.h>
+#else
 #include "third_party/jsoncpp/include/json/json.h"
+#endif
 #define MOZC_JSONCPP_JSON_H_INCLUDED
 #endif  // !MOZC_JSONCPP_JSON_H_INCLUDED