blob: dd67b3508a5698c593caafdabee63e40e814a21d [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 III8c5f28c2022-12-07 01:21:36 -080055 'numeric/endian.cpp',
William A. Kennington III6945d2d2022-12-03 16:54:36 -080056 'pinned.cpp',
57 'raw.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070058 'signal.cpp',
William A. Kennington III60479702022-12-07 02:55:24 -080059 'str/cat.cpp',
William A. Kennington III48a470a2022-12-10 17:09:59 -080060 'str/cexpr.cpp',
William A. Kennington III521475e2022-12-12 16:51:44 -080061 'str/maps.cpp',
William A. Kennington III6945d2d2022-12-03 16:54:36 -080062 'util/cexec.cpp',
William A. Kennington IIIdb1bdbc2023-01-09 16:02:13 -080063 'variant.cpp',
William A. Kennington IIIf2ddf512022-09-20 15:36:44 -070064 'zstring.cpp',
William A. Kennington III61a81bc2022-09-19 17:46:49 -070065 'zstring_view.cpp',
William A. Kennington III45754242021-04-28 12:48:31 -070066]
67
William A. Kennington III7613a5e2022-07-13 16:25:00 -070068if has_fd
William A. Kennington III45754242021-04-28 12:48:31 -070069 stdplus_srcs += [
William A. Kennington IIIaa4fcfc2022-08-23 16:35:10 -070070 'fd/atomic.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070071 'fd/create.cpp',
72 'fd/dupable.cpp',
William A. Kennington III4f5711c2022-08-12 17:01:53 -070073 'fd/fmt.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070074 'fd/impl.cpp',
William A. Kennington III9a512c92022-08-12 15:15:55 -070075 'fd/line.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070076 'fd/managed.cpp',
77 'fd/mmap.cpp',
78 'fd/ops.cpp',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070079 ]
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070080endif
81
William A. Kennington III97e39472019-04-03 13:22:32 -070082stdplus_lib = library(
William A. Kennington III15982f62019-01-31 14:43:41 -080083 'stdplus',
William A. Kennington III45754242021-04-28 12:48:31 -070084 stdplus_srcs,
William A. Kennington III97e39472019-04-03 13:22:32 -070085 include_directories: stdplus_headers,
William A. Kennington III15982f62019-01-31 14:43:41 -080086 implicit_include_directories: false,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070087 dependencies: stdplus_deps,
William A. Kennington III1937ef62019-03-28 03:24:57 -070088 version: meson.project_version(),
William A. Kennington III15982f62019-01-31 14:43:41 -080089 install: true)
90
William A. Kennington III3acf92b2021-04-16 13:33:50 -070091stdplus_dep = declare_dependency(
William A. Kennington IIIe0990382019-10-18 02:10:25 -070092 dependencies: stdplus_deps,
William A. Kennington III97e39472019-04-03 13:22:32 -070093 include_directories: stdplus_headers,
94 link_with: stdplus_lib)
95
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070096stdplus_reqs = []
97foreach dep : stdplus_deps
98 if dep.type_name() == 'pkgconfig'
William A. Kennington III285fbcb2021-01-24 18:16:20 -080099 stdplus_reqs += dep
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700100 endif
101endforeach
102
William A. Kennington III15982f62019-01-31 14:43:41 -0800103import('pkgconfig').generate(
William A. Kennington III285fbcb2021-01-24 18:16:20 -0800104 stdplus_lib,
William A. Kennington III15982f62019-01-31 14:43:41 -0800105 description: 'C++ helper utilities',
106 version: meson.project_version(),
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700107 requires: stdplus_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700108
109if has_dl
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700110 stdplus_dl_deps = [
111 stdplus_dep,
112 dl_dep,
113 ]
114
115 stdplus_dl_pre = declare_dependency(
116 include_directories: stdplus_dl_headers,
117 dependencies: stdplus_dl_deps)
118
119 stdplus_dl_lib = library(
120 'stdplus-dl',
121 'dl.cpp',
122 dependencies: stdplus_dl_pre,
123 implicit_include_directories: false,
124 version: meson.project_version(),
125 install: true)
126
127 stdplus_dl_dep = declare_dependency(
128 dependencies: stdplus_dl_pre,
129 link_with: stdplus_dl_lib)
130
131 stdplus_dl_reqs = []
132 foreach dep : stdplus_dl_deps
133 if dep.type_name() == 'pkgconfig'
134 stdplus_dl_reqs += dep
135 endif
136 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700137
138 import('pkgconfig').generate(
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700139 stdplus_dl_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700140 description: 'C++ helper utilities',
141 version: meson.project_version(),
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700142 requires: stdplus_dl_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700143endif
144
145if has_fd
146 stdplus_fd_dep = stdplus_dep
147
148 import('pkgconfig').generate(
149 stdplus_lib,
150 name: 'stdplus-fd',
151 description: 'C++ helper utilities',
152 version: meson.project_version(),
153 requires: stdplus_reqs)
154endif
155
156if has_io_uring
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700157 stdplus_io_uring_deps = [
158 stdplus_dep,
159 stdplus_fd_dep,
160 io_uring_dep,
161 ]
162
163 stdplus_io_uring_pre = declare_dependency(
164 include_directories: stdplus_io_uring_headers,
165 dependencies: stdplus_io_uring_deps)
166
167 stdplus_io_uring_lib = library(
168 'stdplus-io_uring',
169 'io_uring.cpp',
170 dependencies: stdplus_io_uring_pre,
171 implicit_include_directories: false,
172 version: meson.project_version(),
173 install: true)
174
175 stdplus_io_uring_dep = declare_dependency(
176 dependencies: stdplus_io_uring_pre,
177 link_with: stdplus_io_uring_lib)
178
179 stdplus_io_uring_reqs = []
180 foreach dep : stdplus_io_uring_deps
181 if dep.type_name() == 'pkgconfig'
182 stdplus_io_uring_reqs += dep
183 endif
184 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700185
186 import('pkgconfig').generate(
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700187 stdplus_io_uring_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700188 description: 'C++ helper utilities',
189 version: meson.project_version(),
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700190 requires: stdplus_io_uring_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700191endif
William A. Kennington III953de362022-07-13 17:32:55 -0700192
193if has_gtest
194 stdplus_gtest_deps = [
195 fmt_dep,
196 gtest_dep,
197 ]
198
199 stdplus_gtest_pre = declare_dependency(
200 include_directories: stdplus_gtest_headers,
201 dependencies: stdplus_gtest_deps)
202
203 stdplus_gtest_lib = library(
204 'stdplus-gtest',
205 'gtest/tmp.cpp',
206 dependencies: stdplus_gtest_pre,
207 implicit_include_directories: false,
208 version: meson.project_version(),
209 install: true)
210
211 stdplus_gtest_dep = declare_dependency(
212 dependencies: stdplus_gtest_pre,
213 link_with: stdplus_gtest_lib)
214
215 stdplus_gtest_reqs = []
216 foreach dep : stdplus_gtest_deps
217 if dep.type_name() == 'pkgconfig'
218 stdplus_gtest_reqs += dep
219 endif
220 endforeach
221
222 import('pkgconfig').generate(
223 stdplus_gtest_lib,
224 description: 'C++ helper utilities',
225 version: meson.project_version(),
226 requires: stdplus_gtest_reqs)
William A. Kennington III2030ea52022-07-19 17:06:39 -0700227
228 install_data(
229 'run_with_tmp',
230 install_mode: 'rwxr-xr-x',
231 install_dir: get_option('bindir'))
232
233 meson.override_find_program('run_with_tmp', files('run_with_tmp'))
William A. Kennington III953de362022-07-13 17:32:55 -0700234endif
William A. Kennington III2030ea52022-07-19 17:06:39 -0700235
236run_with_tmp = find_program('run_with_tmp', native: true)