blob: 90afee1ce8e90a869156fd926673e3ef102d623e [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 IIIfc955ab2020-08-07 14:42:54 -070046 'debug/lifetime.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070047 'exception.cpp',
William A. Kennington III6945d2d2022-12-03 16:54:36 -080048 'flags.cpp',
William A. Kennington IIIece19432023-07-15 03:17:24 -070049 'function_view.cpp',
William A. Kennington III6945d2d2022-12-03 16:54:36 -080050 'handle/copyable.cpp',
51 'handle/managed.cpp',
William A. Kennington III403cda22022-12-12 15:52:35 -080052 'hash.cpp',
William A. Kennington III85149ee2023-01-03 18:15:47 -080053 'hash/array.cpp',
William A. Kennington IIIb07a2eb2023-01-03 18:14:40 -080054 'hash/tuple.cpp',
William A. Kennington IIIb25086a2023-01-09 18:53:29 -080055 'net/addr/ether.cpp',
William A. Kennington III9330c872023-01-04 15:41:53 -080056 'net/addr/ip.cpp',
William A. Kennington IIIbe3fb712023-12-17 19:14:56 -080057 'net/addr/sock.cpp',
William A. Kennington III14dd4eb2023-01-12 10:51:12 -080058 'net/addr/subnet.cpp',
William A. Kennington III8c5f28c2022-12-07 01:21:36 -080059 'numeric/endian.cpp',
William A. Kennington IIIcda3c1e2022-12-03 16:56:19 -080060 'numeric/str.cpp',
William A. Kennington III6945d2d2022-12-03 16:54:36 -080061 'pinned.cpp',
William A. Kennington III0475b6d2023-07-21 14:28:54 -070062 'print.cpp',
William A. Kennington III6945d2d2022-12-03 16:54:36 -080063 'raw.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070064 'signal.cpp',
William A. Kennington III3c7107f2023-06-13 15:13:50 -070065 'str/buf.cpp',
William A. Kennington III60479702022-12-07 02:55:24 -080066 'str/cat.cpp',
William A. Kennington III48a470a2022-12-10 17:09:59 -080067 'str/cexpr.cpp',
William A. Kennington III0e844d52022-12-06 23:57:32 -080068 'str/conv.cpp',
William A. Kennington III521475e2022-12-12 16:51:44 -080069 'str/maps.cpp',
William A. Kennington III6945d2d2022-12-03 16:54:36 -080070 'util/cexec.cpp',
William A. Kennington IIIdb1bdbc2023-01-09 16:02:13 -080071 'variant.cpp',
William A. Kennington IIIf2ddf512022-09-20 15:36:44 -070072 'zstring.cpp',
William A. Kennington III61a81bc2022-09-19 17:46:49 -070073 'zstring_view.cpp',
William A. Kennington III45754242021-04-28 12:48:31 -070074]
75
William A. Kennington III7613a5e2022-07-13 16:25:00 -070076if has_fd
William A. Kennington III45754242021-04-28 12:48:31 -070077 stdplus_srcs += [
William A. Kennington IIIaa4fcfc2022-08-23 16:35:10 -070078 'fd/atomic.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070079 'fd/create.cpp',
80 'fd/dupable.cpp',
William A. Kennington III4f5711c2022-08-12 17:01:53 -070081 'fd/fmt.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070082 'fd/impl.cpp',
William A. Kennington III9a512c92022-08-12 15:15:55 -070083 'fd/line.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070084 'fd/managed.cpp',
85 'fd/mmap.cpp',
86 'fd/ops.cpp',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070087 ]
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070088endif
89
William A. Kennington III97e39472019-04-03 13:22:32 -070090stdplus_lib = library(
William A. Kennington III15982f62019-01-31 14:43:41 -080091 'stdplus',
William A. Kennington III45754242021-04-28 12:48:31 -070092 stdplus_srcs,
William A. Kennington III97e39472019-04-03 13:22:32 -070093 include_directories: stdplus_headers,
William A. Kennington III15982f62019-01-31 14:43:41 -080094 implicit_include_directories: false,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070095 dependencies: stdplus_deps,
William A. Kennington III1937ef62019-03-28 03:24:57 -070096 version: meson.project_version(),
William A. Kennington IIIb5d19142023-12-07 15:20:01 -080097 build_by_default: not meson.is_subproject(),
William A. Kennington III15982f62019-01-31 14:43:41 -080098 install: true)
99
William A. Kennington III3acf92b2021-04-16 13:33:50 -0700100stdplus_dep = declare_dependency(
William A. Kennington IIIe0990382019-10-18 02:10:25 -0700101 dependencies: stdplus_deps,
William A. Kennington III97e39472019-04-03 13:22:32 -0700102 include_directories: stdplus_headers,
103 link_with: stdplus_lib)
104
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700105stdplus_reqs = []
106foreach dep : stdplus_deps
107 if dep.type_name() == 'pkgconfig'
William A. Kennington III285fbcb2021-01-24 18:16:20 -0800108 stdplus_reqs += dep
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700109 endif
110endforeach
111
William A. Kennington III15982f62019-01-31 14:43:41 -0800112import('pkgconfig').generate(
William A. Kennington III285fbcb2021-01-24 18:16:20 -0800113 stdplus_lib,
William A. Kennington III15982f62019-01-31 14:43:41 -0800114 description: 'C++ helper utilities',
115 version: meson.project_version(),
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700116 requires: stdplus_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700117
118if has_dl
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700119 stdplus_dl_deps = [
120 stdplus_dep,
121 dl_dep,
122 ]
123
124 stdplus_dl_pre = declare_dependency(
125 include_directories: stdplus_dl_headers,
126 dependencies: stdplus_dl_deps)
127
128 stdplus_dl_lib = library(
129 'stdplus-dl',
130 'dl.cpp',
131 dependencies: stdplus_dl_pre,
132 implicit_include_directories: false,
133 version: meson.project_version(),
William A. Kennington IIIb5d19142023-12-07 15:20:01 -0800134 build_by_default: not meson.is_subproject(),
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700135 install: true)
136
137 stdplus_dl_dep = declare_dependency(
138 dependencies: stdplus_dl_pre,
139 link_with: stdplus_dl_lib)
140
141 stdplus_dl_reqs = []
142 foreach dep : stdplus_dl_deps
143 if dep.type_name() == 'pkgconfig'
144 stdplus_dl_reqs += dep
145 endif
146 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700147
148 import('pkgconfig').generate(
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700149 stdplus_dl_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700150 description: 'C++ helper utilities',
151 version: meson.project_version(),
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700152 requires: stdplus_dl_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700153endif
154
155if has_fd
156 stdplus_fd_dep = stdplus_dep
157
158 import('pkgconfig').generate(
159 stdplus_lib,
160 name: 'stdplus-fd',
161 description: 'C++ helper utilities',
162 version: meson.project_version(),
163 requires: stdplus_reqs)
164endif
165
166if has_io_uring
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700167 stdplus_io_uring_deps = [
168 stdplus_dep,
169 stdplus_fd_dep,
170 io_uring_dep,
171 ]
172
173 stdplus_io_uring_pre = declare_dependency(
174 include_directories: stdplus_io_uring_headers,
175 dependencies: stdplus_io_uring_deps)
176
177 stdplus_io_uring_lib = library(
178 'stdplus-io_uring',
179 'io_uring.cpp',
180 dependencies: stdplus_io_uring_pre,
181 implicit_include_directories: false,
182 version: meson.project_version(),
William A. Kennington IIIb5d19142023-12-07 15:20:01 -0800183 build_by_default: not meson.is_subproject(),
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700184 install: true)
185
186 stdplus_io_uring_dep = declare_dependency(
187 dependencies: stdplus_io_uring_pre,
188 link_with: stdplus_io_uring_lib)
189
190 stdplus_io_uring_reqs = []
191 foreach dep : stdplus_io_uring_deps
192 if dep.type_name() == 'pkgconfig'
193 stdplus_io_uring_reqs += dep
194 endif
195 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700196
197 import('pkgconfig').generate(
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700198 stdplus_io_uring_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700199 description: 'C++ helper utilities',
200 version: meson.project_version(),
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700201 requires: stdplus_io_uring_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700202endif
William A. Kennington III953de362022-07-13 17:32:55 -0700203
204if has_gtest
205 stdplus_gtest_deps = [
206 fmt_dep,
207 gtest_dep,
208 ]
209
210 stdplus_gtest_pre = declare_dependency(
211 include_directories: stdplus_gtest_headers,
212 dependencies: stdplus_gtest_deps)
213
214 stdplus_gtest_lib = library(
215 'stdplus-gtest',
216 'gtest/tmp.cpp',
217 dependencies: stdplus_gtest_pre,
218 implicit_include_directories: false,
219 version: meson.project_version(),
William A. Kennington IIIb5d19142023-12-07 15:20:01 -0800220 build_by_default: not meson.is_subproject(),
William A. Kennington III953de362022-07-13 17:32:55 -0700221 install: true)
222
223 stdplus_gtest_dep = declare_dependency(
224 dependencies: stdplus_gtest_pre,
225 link_with: stdplus_gtest_lib)
226
227 stdplus_gtest_reqs = []
228 foreach dep : stdplus_gtest_deps
229 if dep.type_name() == 'pkgconfig'
230 stdplus_gtest_reqs += dep
231 endif
232 endforeach
233
234 import('pkgconfig').generate(
235 stdplus_gtest_lib,
236 description: 'C++ helper utilities',
237 version: meson.project_version(),
238 requires: stdplus_gtest_reqs)
William A. Kennington III2030ea52022-07-19 17:06:39 -0700239
240 install_data(
241 'run_with_tmp',
242 install_mode: 'rwxr-xr-x',
243 install_dir: get_option('bindir'))
244
245 meson.override_find_program('run_with_tmp', files('run_with_tmp'))
William A. Kennington III953de362022-07-13 17:32:55 -0700246endif
William A. Kennington III2030ea52022-07-19 17:06:39 -0700247
248run_with_tmp = find_program('run_with_tmp', native: true)