@@ -37,6 +37,39 @@ absl_string_view_dep = dependency(
37
37
default_options : [' cpp_std=c++17' ],
38
38
)
39
39
40
+ if meson .version().version_compare(' >=1.7.0' )
41
+ atomic_dep = dependency (
42
+ ' atomic' ,
43
+ required : false ,
44
+ )
45
+ else
46
+ atomic_dep = cc.find_library (
47
+ ' atomic' ,
48
+ required : false ,
49
+ )
50
+ endif
51
+
52
+ # Make reasonable effort (volatile) to prevent the compiler from optimizing the atomic away without using tested
53
+ # functionality.
54
+ if not cc.links(
55
+ '''
56
+ #include <atomic>
57
+ #include <cstdint>
58
+
59
+ int main() {
60
+ volatile std::atomic<std::uint64_t> testvar;
61
+ // The line below will lead to
62
+ // undefined reference to `__atomic_fetch_add_8'
63
+ // on armv6l to give an example.
64
+ volatile auto unused = testvar.fetch_add(0);
65
+ }
66
+ ''' ,
67
+ name : ' Check if libatomic is required' ,
68
+ dependencies : atomic_dep,
69
+ )
70
+ error (' Host machine cannot handle atomics!' )
71
+ endif
72
+
40
73
deps = [
41
74
dependency (' absl_base' ),
42
75
dependency (' absl_cord' ),
@@ -58,6 +91,7 @@ deps = [
58
91
' dbghelp' ,
59
92
required : host_machine .system() == ' windows' ,
60
93
),
94
+ atomic_dep,
61
95
]
62
96
63
97
incdir = include_directories (' src' )
@@ -136,6 +170,7 @@ protobuf_lite_dep = declare_dependency(
136
170
compile_args : imp,
137
171
link_with : libprotobuf_lite,
138
172
include_directories : incdir,
173
+ dependencies : atomic_dep,
139
174
)
140
175
141
176
libprotobuf_src = files (
@@ -218,8 +253,8 @@ libprotobuf_src = files(
218
253
' src/google/protobuf/wrappers.pb.cc' ,
219
254
)
220
255
libprotobuf_linker_args = (is_msvc ? [
221
- ' /export:??$MergeFrom@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@RepeatedPtrFieldBase@internal@protobuf@google@@QEAAXAEBV0123@@Z' ,
222
- ] : []
256
+ ' /export:??$MergeFrom@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@RepeatedPtrFieldBase@internal@protobuf@google@@QEAAXAEBV0123@@Z' ,
257
+ ] : []
223
258
)
224
259
libprotobuf = library (
225
260
' protobuf' ,
0 commit comments