blob: 6d17d3db1062ee0761de18cb6b7909f005d18389 [file] [log] [blame]
William A. Kennington IIIe0990382019-10-18 02:10:25 -07001fmt_dep = dependency('fmt', required: false)
William A. Kennington IIIe0990382019-10-18 02:10:25 -07002if not fmt_dep.found()
William A. Kennington IIIb5d1c582021-04-16 13:41:39 -07003 fmt_opts = import('cmake').subproject_options()
4 fmt_opts.add_cmake_defines({
5 'CMAKE_POSITION_INDEPENDENT_CODE': 'ON',
6 'MASTER_PROJECT': 'OFF',
7 })
William A. Kennington IIIe0990382019-10-18 02:10:25 -07008 fmt_proj = import('cmake').subproject(
9 'fmt',
William A. Kennington IIIb5d1c582021-04-16 13:41:39 -070010 options: fmt_opts,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070011 required: false)
12 assert(fmt_proj.found(), 'fmtlib is required')
13 fmt_dep = fmt_proj.dependency('fmt')
14endif
15
William A. Kennington III08d84432022-09-21 10:57:58 -070016# Function2 might not have a pkg-config. It is header only so just make
17# sure we can access the needed symbols from the header.
18function2_dep = dependency('function2', required: false)
19has_function2 = meson.get_compiler('cpp').has_header_symbol(
20 'function2/function2.hpp',
21 'fu2::unique_function',
22 dependencies: function2_dep,
23 required: false
24)
25if not has_function2
26 function2_opts = import('cmake').subproject_options()
27 function2_opts.add_cmake_defines({'BUILD_TESTING': 'OFF'})
28 function2_proj = import('cmake').subproject(
29 'function2',
30 options: function2_opts,
31 required: false
32 )
33 assert(function2_proj.found(), 'function2 is required')
34 if function2_proj.found()
35 function2_dep = function2_proj.dependency('function2')
36 endif
37endif
38
William A. Kennington IIIe0990382019-10-18 02:10:25 -070039stdplus_deps = [
40 fmt_dep,
William A. Kennington III08d84432022-09-21 10:57:58 -070041 function2_dep,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070042]
43
William A. Kennington III45754242021-04-28 12:48:31 -070044stdplus_srcs = [
William A. Kennington III6945d2d2022-12-03 16:54:36 -080045 'cancel.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070046 'exception.cpp',
William A. Kennington III6945d2d2022-12-03 16:54:36 -080047 'flags.cpp',
48 'handle/copyable.cpp',
49 'handle/managed.cpp',
William A. Kennington III403cda22022-12-12 15:52:35 -080050 'hash.cpp',
William A. Kennington III85149ee2023-01-03 18:15:47 -080051 'hash/array.cpp',
William A. Kennington IIIb07a2eb2023-01-03 18:14:40 -080052 'hash/tuple.cpp',
William A. Kennington IIIb25086a2023-01-09 18:53:29 -080053 'net/addr/ether.cpp',
William A. Kennington III9330c872023-01-04 15:41:53 -080054 'net/addr/ip.cpp',
William A. Kennington III14dd4eb2023-01-12 10:51:12 -080055 'net/addr/subnet.cpp',
William A. Kennington III8c5f28c2022-12-07 01:21:36 -080056 'numeric/endian.cpp',
William A. Kennington IIIcda3c1e2022-12-03 16:56:19 -080057 'numeric/str.cpp',
William A. Kennington III6945d2d2022-12-03 16:54:36 -080058 'pinned.cpp',
59 'raw.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070060 'signal.cpp',
William A. Kennington III3c7107f2023-06-13 15:13:50 -070061 'str/buf.cpp',
William A. Kennington III60479702022-12-07 02:55:24 -080062 'str/cat.cpp',
William A. Kennington III48a470a2022-12-10 17:09:59 -080063 'str/cexpr.cpp',
William A. Kennington III0e844d52022-12-06 23:57:32 -080064 'str/conv.cpp',
William A. Kennington III521475e2022-12-12 16:51:44 -080065 'str/maps.cpp',
William A. Kennington III6945d2d2022-12-03 16:54:36 -080066 'util/cexec.cpp',
William A. Kennington IIIdb1bdbc2023-01-09 16:02:13 -080067 'variant.cpp',
William A. Kennington IIIf2ddf512022-09-20 15:36:44 -070068 'zstring.cpp',
William A. Kennington III61a81bc2022-09-19 17:46:49 -070069 'zstring_view.cpp',
William A. Kennington III45754242021-04-28 12:48:31 -070070]
71
William A. Kennington III7613a5e2022-07-13 16:25:00 -070072if has_fd
William A. Kennington III45754242021-04-28 12:48:31 -070073 stdplus_srcs += [
William A. Kennington IIIaa4fcfc2022-08-23 16:35:10 -070074 'fd/atomic.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070075 'fd/create.cpp',
76 'fd/dupable.cpp',
William A. Kennington III4f5711c2022-08-12 17:01:53 -070077 'fd/fmt.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070078 'fd/impl.cpp',
William A. Kennington III9a512c92022-08-12 15:15:55 -070079 'fd/line.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070080 'fd/managed.cpp',
81 'fd/mmap.cpp',
82 'fd/ops.cpp',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070083 ]
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070084endif
85
William A. Kennington III97e39472019-04-03 13:22:32 -070086stdplus_lib = library(
William A. Kennington III15982f62019-01-31 14:43:41 -080087 'stdplus',
William A. Kennington III45754242021-04-28 12:48:31 -070088 stdplus_srcs,
William A. Kennington III97e39472019-04-03 13:22:32 -070089 include_directories: stdplus_headers,
William A. Kennington III15982f62019-01-31 14:43:41 -080090 implicit_include_directories: false,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070091 dependencies: stdplus_deps,
William A. Kennington III1937ef62019-03-28 03:24:57 -070092 version: meson.project_version(),
William A. Kennington III15982f62019-01-31 14:43:41 -080093 install: true)
94
William A. Kennington III3acf92b2021-04-16 13:33:50 -070095stdplus_dep = declare_dependency(
William A. Kennington IIIe0990382019-10-18 02:10:25 -070096 dependencies: stdplus_deps,
William A. Kennington III97e39472019-04-03 13:22:32 -070097 include_directories: stdplus_headers,
98 link_with: stdplus_lib)
99
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700100stdplus_reqs = []
101foreach dep : stdplus_deps
102 if dep.type_name() == 'pkgconfig'
William A. Kennington III285fbcb2021-01-24 18:16:20 -0800103 stdplus_reqs += dep
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700104 endif
105endforeach
106
William A. Kennington III15982f62019-01-31 14:43:41 -0800107import('pkgconfig').generate(
William A. Kennington III285fbcb2021-01-24 18:16:20 -0800108 stdplus_lib,
William A. Kennington III15982f62019-01-31 14:43:41 -0800109 description: 'C++ helper utilities',
110 version: meson.project_version(),
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700111 requires: stdplus_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700112
113if has_dl
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700114 stdplus_dl_deps = [
115 stdplus_dep,
116 dl_dep,
117 ]
118
119 stdplus_dl_pre = declare_dependency(
120 include_directories: stdplus_dl_headers,
121 dependencies: stdplus_dl_deps)
122
123 stdplus_dl_lib = library(
124 'stdplus-dl',
125 'dl.cpp',
126 dependencies: stdplus_dl_pre,
127 implicit_include_directories: false,
128 version: meson.project_version(),
129 install: true)
130
131 stdplus_dl_dep = declare_dependency(
132 dependencies: stdplus_dl_pre,
133 link_with: stdplus_dl_lib)
134
135 stdplus_dl_reqs = []
136 foreach dep : stdplus_dl_deps
137 if dep.type_name() == 'pkgconfig'
138 stdplus_dl_reqs += dep
139 endif
140 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700141
142 import('pkgconfig').generate(
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700143 stdplus_dl_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700144 description: 'C++ helper utilities',
145 version: meson.project_version(),
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700146 requires: stdplus_dl_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700147endif
148
149if has_fd
150 stdplus_fd_dep = stdplus_dep
151
152 import('pkgconfig').generate(
153 stdplus_lib,
154 name: 'stdplus-fd',
155 description: 'C++ helper utilities',
156 version: meson.project_version(),
157 requires: stdplus_reqs)
158endif
159
160if has_io_uring
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700161 stdplus_io_uring_deps = [
162 stdplus_dep,
163 stdplus_fd_dep,
164 io_uring_dep,
165 ]
166
167 stdplus_io_uring_pre = declare_dependency(
168 include_directories: stdplus_io_uring_headers,
169 dependencies: stdplus_io_uring_deps)
170
171 stdplus_io_uring_lib = library(
172 'stdplus-io_uring',
173 'io_uring.cpp',
174 dependencies: stdplus_io_uring_pre,
175 implicit_include_directories: false,
176 version: meson.project_version(),
177 install: true)
178
179 stdplus_io_uring_dep = declare_dependency(
180 dependencies: stdplus_io_uring_pre,
181 link_with: stdplus_io_uring_lib)
182
183 stdplus_io_uring_reqs = []
184 foreach dep : stdplus_io_uring_deps
185 if dep.type_name() == 'pkgconfig'
186 stdplus_io_uring_reqs += dep
187 endif
188 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700189
190 import('pkgconfig').generate(
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700191 stdplus_io_uring_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700192 description: 'C++ helper utilities',
193 version: meson.project_version(),
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700194 requires: stdplus_io_uring_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700195endif
William A. Kennington III953de362022-07-13 17:32:55 -0700196
197if has_gtest
198 stdplus_gtest_deps = [
199 fmt_dep,
200 gtest_dep,
201 ]
202
203 stdplus_gtest_pre = declare_dependency(
204 include_directories: stdplus_gtest_headers,
205 dependencies: stdplus_gtest_deps)
206
207 stdplus_gtest_lib = library(
208 'stdplus-gtest',
209 'gtest/tmp.cpp',
210 dependencies: stdplus_gtest_pre,
211 implicit_include_directories: false,
212 version: meson.project_version(),
213 install: true)
214
215 stdplus_gtest_dep = declare_dependency(
216 dependencies: stdplus_gtest_pre,
217 link_with: stdplus_gtest_lib)
218
219 stdplus_gtest_reqs = []
220 foreach dep : stdplus_gtest_deps
221 if dep.type_name() == 'pkgconfig'
222 stdplus_gtest_reqs += dep
223 endif
224 endforeach
225
226 import('pkgconfig').generate(
227 stdplus_gtest_lib,
228 description: 'C++ helper utilities',
229 version: meson.project_version(),
230 requires: stdplus_gtest_reqs)
William A. Kennington III2030ea52022-07-19 17:06:39 -0700231
232 install_data(
233 'run_with_tmp',
234 install_mode: 'rwxr-xr-x',
235 install_dir: get_option('bindir'))
236
237 meson.override_find_program('run_with_tmp', files('run_with_tmp'))
William A. Kennington III953de362022-07-13 17:32:55 -0700238endif
William A. Kennington III2030ea52022-07-19 17:06:39 -0700239
240run_with_tmp = find_program('run_with_tmp', native: true)