blob: 7c4dabf7ca02f03ca71f7c5fcd053407b7201358 [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',
50 'pinned.cpp',
51 'raw.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070052 'signal.cpp',
William A. Kennington III60479702022-12-07 02:55:24 -080053 'str/cat.cpp',
William A. Kennington III48a470a2022-12-10 17:09:59 -080054 'str/cexpr.cpp',
William A. Kennington III6945d2d2022-12-03 16:54:36 -080055 'util/cexec.cpp',
William A. Kennington IIIf2ddf512022-09-20 15:36:44 -070056 'zstring.cpp',
William A. Kennington III61a81bc2022-09-19 17:46:49 -070057 'zstring_view.cpp',
William A. Kennington III45754242021-04-28 12:48:31 -070058]
59
William A. Kennington III7613a5e2022-07-13 16:25:00 -070060if has_fd
William A. Kennington III45754242021-04-28 12:48:31 -070061 stdplus_srcs += [
William A. Kennington IIIaa4fcfc2022-08-23 16:35:10 -070062 'fd/atomic.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070063 'fd/create.cpp',
64 'fd/dupable.cpp',
William A. Kennington III4f5711c2022-08-12 17:01:53 -070065 'fd/fmt.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070066 'fd/impl.cpp',
William A. Kennington III9a512c92022-08-12 15:15:55 -070067 'fd/line.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070068 'fd/managed.cpp',
69 'fd/mmap.cpp',
70 'fd/ops.cpp',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070071 ]
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070072endif
73
William A. Kennington III97e39472019-04-03 13:22:32 -070074stdplus_lib = library(
William A. Kennington III15982f62019-01-31 14:43:41 -080075 'stdplus',
William A. Kennington III45754242021-04-28 12:48:31 -070076 stdplus_srcs,
William A. Kennington III97e39472019-04-03 13:22:32 -070077 include_directories: stdplus_headers,
William A. Kennington III15982f62019-01-31 14:43:41 -080078 implicit_include_directories: false,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070079 dependencies: stdplus_deps,
William A. Kennington III1937ef62019-03-28 03:24:57 -070080 version: meson.project_version(),
William A. Kennington III15982f62019-01-31 14:43:41 -080081 install: true)
82
William A. Kennington III3acf92b2021-04-16 13:33:50 -070083stdplus_dep = declare_dependency(
William A. Kennington IIIe0990382019-10-18 02:10:25 -070084 dependencies: stdplus_deps,
William A. Kennington III97e39472019-04-03 13:22:32 -070085 include_directories: stdplus_headers,
86 link_with: stdplus_lib)
87
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070088stdplus_reqs = []
89foreach dep : stdplus_deps
90 if dep.type_name() == 'pkgconfig'
William A. Kennington III285fbcb2021-01-24 18:16:20 -080091 stdplus_reqs += dep
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070092 endif
93endforeach
94
William A. Kennington III15982f62019-01-31 14:43:41 -080095import('pkgconfig').generate(
William A. Kennington III285fbcb2021-01-24 18:16:20 -080096 stdplus_lib,
William A. Kennington III15982f62019-01-31 14:43:41 -080097 description: 'C++ helper utilities',
98 version: meson.project_version(),
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070099 requires: stdplus_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700100
101if has_dl
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700102 stdplus_dl_deps = [
103 stdplus_dep,
104 dl_dep,
105 ]
106
107 stdplus_dl_pre = declare_dependency(
108 include_directories: stdplus_dl_headers,
109 dependencies: stdplus_dl_deps)
110
111 stdplus_dl_lib = library(
112 'stdplus-dl',
113 'dl.cpp',
114 dependencies: stdplus_dl_pre,
115 implicit_include_directories: false,
116 version: meson.project_version(),
117 install: true)
118
119 stdplus_dl_dep = declare_dependency(
120 dependencies: stdplus_dl_pre,
121 link_with: stdplus_dl_lib)
122
123 stdplus_dl_reqs = []
124 foreach dep : stdplus_dl_deps
125 if dep.type_name() == 'pkgconfig'
126 stdplus_dl_reqs += dep
127 endif
128 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700129
130 import('pkgconfig').generate(
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700131 stdplus_dl_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700132 description: 'C++ helper utilities',
133 version: meson.project_version(),
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700134 requires: stdplus_dl_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700135endif
136
137if has_fd
138 stdplus_fd_dep = stdplus_dep
139
140 import('pkgconfig').generate(
141 stdplus_lib,
142 name: 'stdplus-fd',
143 description: 'C++ helper utilities',
144 version: meson.project_version(),
145 requires: stdplus_reqs)
146endif
147
148if has_io_uring
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700149 stdplus_io_uring_deps = [
150 stdplus_dep,
151 stdplus_fd_dep,
152 io_uring_dep,
153 ]
154
155 stdplus_io_uring_pre = declare_dependency(
156 include_directories: stdplus_io_uring_headers,
157 dependencies: stdplus_io_uring_deps)
158
159 stdplus_io_uring_lib = library(
160 'stdplus-io_uring',
161 'io_uring.cpp',
162 dependencies: stdplus_io_uring_pre,
163 implicit_include_directories: false,
164 version: meson.project_version(),
165 install: true)
166
167 stdplus_io_uring_dep = declare_dependency(
168 dependencies: stdplus_io_uring_pre,
169 link_with: stdplus_io_uring_lib)
170
171 stdplus_io_uring_reqs = []
172 foreach dep : stdplus_io_uring_deps
173 if dep.type_name() == 'pkgconfig'
174 stdplus_io_uring_reqs += dep
175 endif
176 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700177
178 import('pkgconfig').generate(
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700179 stdplus_io_uring_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700180 description: 'C++ helper utilities',
181 version: meson.project_version(),
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700182 requires: stdplus_io_uring_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700183endif
William A. Kennington III953de362022-07-13 17:32:55 -0700184
185if has_gtest
186 stdplus_gtest_deps = [
187 fmt_dep,
188 gtest_dep,
189 ]
190
191 stdplus_gtest_pre = declare_dependency(
192 include_directories: stdplus_gtest_headers,
193 dependencies: stdplus_gtest_deps)
194
195 stdplus_gtest_lib = library(
196 'stdplus-gtest',
197 'gtest/tmp.cpp',
198 dependencies: stdplus_gtest_pre,
199 implicit_include_directories: false,
200 version: meson.project_version(),
201 install: true)
202
203 stdplus_gtest_dep = declare_dependency(
204 dependencies: stdplus_gtest_pre,
205 link_with: stdplus_gtest_lib)
206
207 stdplus_gtest_reqs = []
208 foreach dep : stdplus_gtest_deps
209 if dep.type_name() == 'pkgconfig'
210 stdplus_gtest_reqs += dep
211 endif
212 endforeach
213
214 import('pkgconfig').generate(
215 stdplus_gtest_lib,
216 description: 'C++ helper utilities',
217 version: meson.project_version(),
218 requires: stdplus_gtest_reqs)
William A. Kennington III2030ea52022-07-19 17:06:39 -0700219
220 install_data(
221 'run_with_tmp',
222 install_mode: 'rwxr-xr-x',
223 install_dir: get_option('bindir'))
224
225 meson.override_find_program('run_with_tmp', files('run_with_tmp'))
William A. Kennington III953de362022-07-13 17:32:55 -0700226endif
William A. Kennington III2030ea52022-07-19 17:06:39 -0700227
228run_with_tmp = find_program('run_with_tmp', native: true)