blob: 2a08ac56ae3d8ad8af6c7aaddb3cb04590d8d2b6 [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 III6945d2d2022-12-03 16:54:36 -080054 'util/cexec.cpp',
William A. Kennington IIIf2ddf512022-09-20 15:36:44 -070055 'zstring.cpp',
William A. Kennington III61a81bc2022-09-19 17:46:49 -070056 'zstring_view.cpp',
William A. Kennington III45754242021-04-28 12:48:31 -070057]
58
William A. Kennington III7613a5e2022-07-13 16:25:00 -070059if has_fd
William A. Kennington III45754242021-04-28 12:48:31 -070060 stdplus_srcs += [
William A. Kennington IIIaa4fcfc2022-08-23 16:35:10 -070061 'fd/atomic.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070062 'fd/create.cpp',
63 'fd/dupable.cpp',
William A. Kennington III4f5711c2022-08-12 17:01:53 -070064 'fd/fmt.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070065 'fd/impl.cpp',
William A. Kennington III9a512c92022-08-12 15:15:55 -070066 'fd/line.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070067 'fd/managed.cpp',
68 'fd/mmap.cpp',
69 'fd/ops.cpp',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070070 ]
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070071endif
72
William A. Kennington III97e39472019-04-03 13:22:32 -070073stdplus_lib = library(
William A. Kennington III15982f62019-01-31 14:43:41 -080074 'stdplus',
William A. Kennington III45754242021-04-28 12:48:31 -070075 stdplus_srcs,
William A. Kennington III97e39472019-04-03 13:22:32 -070076 include_directories: stdplus_headers,
William A. Kennington III15982f62019-01-31 14:43:41 -080077 implicit_include_directories: false,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070078 dependencies: stdplus_deps,
William A. Kennington III1937ef62019-03-28 03:24:57 -070079 version: meson.project_version(),
William A. Kennington III15982f62019-01-31 14:43:41 -080080 install: true)
81
William A. Kennington III3acf92b2021-04-16 13:33:50 -070082stdplus_dep = declare_dependency(
William A. Kennington IIIe0990382019-10-18 02:10:25 -070083 dependencies: stdplus_deps,
William A. Kennington III97e39472019-04-03 13:22:32 -070084 include_directories: stdplus_headers,
85 link_with: stdplus_lib)
86
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070087stdplus_reqs = []
88foreach dep : stdplus_deps
89 if dep.type_name() == 'pkgconfig'
William A. Kennington III285fbcb2021-01-24 18:16:20 -080090 stdplus_reqs += dep
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070091 endif
92endforeach
93
William A. Kennington III15982f62019-01-31 14:43:41 -080094import('pkgconfig').generate(
William A. Kennington III285fbcb2021-01-24 18:16:20 -080095 stdplus_lib,
William A. Kennington III15982f62019-01-31 14:43:41 -080096 description: 'C++ helper utilities',
97 version: meson.project_version(),
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070098 requires: stdplus_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070099
100if has_dl
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700101 stdplus_dl_deps = [
102 stdplus_dep,
103 dl_dep,
104 ]
105
106 stdplus_dl_pre = declare_dependency(
107 include_directories: stdplus_dl_headers,
108 dependencies: stdplus_dl_deps)
109
110 stdplus_dl_lib = library(
111 'stdplus-dl',
112 'dl.cpp',
113 dependencies: stdplus_dl_pre,
114 implicit_include_directories: false,
115 version: meson.project_version(),
116 install: true)
117
118 stdplus_dl_dep = declare_dependency(
119 dependencies: stdplus_dl_pre,
120 link_with: stdplus_dl_lib)
121
122 stdplus_dl_reqs = []
123 foreach dep : stdplus_dl_deps
124 if dep.type_name() == 'pkgconfig'
125 stdplus_dl_reqs += dep
126 endif
127 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700128
129 import('pkgconfig').generate(
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700130 stdplus_dl_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700131 description: 'C++ helper utilities',
132 version: meson.project_version(),
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700133 requires: stdplus_dl_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700134endif
135
136if has_fd
137 stdplus_fd_dep = stdplus_dep
138
139 import('pkgconfig').generate(
140 stdplus_lib,
141 name: 'stdplus-fd',
142 description: 'C++ helper utilities',
143 version: meson.project_version(),
144 requires: stdplus_reqs)
145endif
146
147if has_io_uring
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700148 stdplus_io_uring_deps = [
149 stdplus_dep,
150 stdplus_fd_dep,
151 io_uring_dep,
152 ]
153
154 stdplus_io_uring_pre = declare_dependency(
155 include_directories: stdplus_io_uring_headers,
156 dependencies: stdplus_io_uring_deps)
157
158 stdplus_io_uring_lib = library(
159 'stdplus-io_uring',
160 'io_uring.cpp',
161 dependencies: stdplus_io_uring_pre,
162 implicit_include_directories: false,
163 version: meson.project_version(),
164 install: true)
165
166 stdplus_io_uring_dep = declare_dependency(
167 dependencies: stdplus_io_uring_pre,
168 link_with: stdplus_io_uring_lib)
169
170 stdplus_io_uring_reqs = []
171 foreach dep : stdplus_io_uring_deps
172 if dep.type_name() == 'pkgconfig'
173 stdplus_io_uring_reqs += dep
174 endif
175 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700176
177 import('pkgconfig').generate(
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700178 stdplus_io_uring_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700179 description: 'C++ helper utilities',
180 version: meson.project_version(),
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700181 requires: stdplus_io_uring_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700182endif
William A. Kennington III953de362022-07-13 17:32:55 -0700183
184if has_gtest
185 stdplus_gtest_deps = [
186 fmt_dep,
187 gtest_dep,
188 ]
189
190 stdplus_gtest_pre = declare_dependency(
191 include_directories: stdplus_gtest_headers,
192 dependencies: stdplus_gtest_deps)
193
194 stdplus_gtest_lib = library(
195 'stdplus-gtest',
196 'gtest/tmp.cpp',
197 dependencies: stdplus_gtest_pre,
198 implicit_include_directories: false,
199 version: meson.project_version(),
200 install: true)
201
202 stdplus_gtest_dep = declare_dependency(
203 dependencies: stdplus_gtest_pre,
204 link_with: stdplus_gtest_lib)
205
206 stdplus_gtest_reqs = []
207 foreach dep : stdplus_gtest_deps
208 if dep.type_name() == 'pkgconfig'
209 stdplus_gtest_reqs += dep
210 endif
211 endforeach
212
213 import('pkgconfig').generate(
214 stdplus_gtest_lib,
215 description: 'C++ helper utilities',
216 version: meson.project_version(),
217 requires: stdplus_gtest_reqs)
William A. Kennington III2030ea52022-07-19 17:06:39 -0700218
219 install_data(
220 'run_with_tmp',
221 install_mode: 'rwxr-xr-x',
222 install_dir: get_option('bindir'))
223
224 meson.override_find_program('run_with_tmp', files('run_with_tmp'))
William A. Kennington III953de362022-07-13 17:32:55 -0700225endif
William A. Kennington III2030ea52022-07-19 17:06:39 -0700226
227run_with_tmp = find_program('run_with_tmp', native: true)