blob: c4662ad205a11d7fac55f6fe0cb1698d542bca3d [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 III6945d2d2022-12-03 16:54:36 -080051 'pinned.cpp',
52 'raw.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070053 'signal.cpp',
William A. Kennington III60479702022-12-07 02:55:24 -080054 'str/cat.cpp',
William A. Kennington III48a470a2022-12-10 17:09:59 -080055 'str/cexpr.cpp',
William A. Kennington III6945d2d2022-12-03 16:54:36 -080056 'util/cexec.cpp',
William A. Kennington IIIf2ddf512022-09-20 15:36:44 -070057 'zstring.cpp',
William A. Kennington III61a81bc2022-09-19 17:46:49 -070058 'zstring_view.cpp',
William A. Kennington III45754242021-04-28 12:48:31 -070059]
60
William A. Kennington III7613a5e2022-07-13 16:25:00 -070061if has_fd
William A. Kennington III45754242021-04-28 12:48:31 -070062 stdplus_srcs += [
William A. Kennington IIIaa4fcfc2022-08-23 16:35:10 -070063 'fd/atomic.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070064 'fd/create.cpp',
65 'fd/dupable.cpp',
William A. Kennington III4f5711c2022-08-12 17:01:53 -070066 'fd/fmt.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070067 'fd/impl.cpp',
William A. Kennington III9a512c92022-08-12 15:15:55 -070068 'fd/line.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070069 'fd/managed.cpp',
70 'fd/mmap.cpp',
71 'fd/ops.cpp',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070072 ]
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070073endif
74
William A. Kennington III97e39472019-04-03 13:22:32 -070075stdplus_lib = library(
William A. Kennington III15982f62019-01-31 14:43:41 -080076 'stdplus',
William A. Kennington III45754242021-04-28 12:48:31 -070077 stdplus_srcs,
William A. Kennington III97e39472019-04-03 13:22:32 -070078 include_directories: stdplus_headers,
William A. Kennington III15982f62019-01-31 14:43:41 -080079 implicit_include_directories: false,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070080 dependencies: stdplus_deps,
William A. Kennington III1937ef62019-03-28 03:24:57 -070081 version: meson.project_version(),
William A. Kennington III15982f62019-01-31 14:43:41 -080082 install: true)
83
William A. Kennington III3acf92b2021-04-16 13:33:50 -070084stdplus_dep = declare_dependency(
William A. Kennington IIIe0990382019-10-18 02:10:25 -070085 dependencies: stdplus_deps,
William A. Kennington III97e39472019-04-03 13:22:32 -070086 include_directories: stdplus_headers,
87 link_with: stdplus_lib)
88
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070089stdplus_reqs = []
90foreach dep : stdplus_deps
91 if dep.type_name() == 'pkgconfig'
William A. Kennington III285fbcb2021-01-24 18:16:20 -080092 stdplus_reqs += dep
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070093 endif
94endforeach
95
William A. Kennington III15982f62019-01-31 14:43:41 -080096import('pkgconfig').generate(
William A. Kennington III285fbcb2021-01-24 18:16:20 -080097 stdplus_lib,
William A. Kennington III15982f62019-01-31 14:43:41 -080098 description: 'C++ helper utilities',
99 version: meson.project_version(),
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700100 requires: stdplus_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700101
102if has_dl
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700103 stdplus_dl_deps = [
104 stdplus_dep,
105 dl_dep,
106 ]
107
108 stdplus_dl_pre = declare_dependency(
109 include_directories: stdplus_dl_headers,
110 dependencies: stdplus_dl_deps)
111
112 stdplus_dl_lib = library(
113 'stdplus-dl',
114 'dl.cpp',
115 dependencies: stdplus_dl_pre,
116 implicit_include_directories: false,
117 version: meson.project_version(),
118 install: true)
119
120 stdplus_dl_dep = declare_dependency(
121 dependencies: stdplus_dl_pre,
122 link_with: stdplus_dl_lib)
123
124 stdplus_dl_reqs = []
125 foreach dep : stdplus_dl_deps
126 if dep.type_name() == 'pkgconfig'
127 stdplus_dl_reqs += dep
128 endif
129 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700130
131 import('pkgconfig').generate(
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700132 stdplus_dl_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700133 description: 'C++ helper utilities',
134 version: meson.project_version(),
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700135 requires: stdplus_dl_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700136endif
137
138if has_fd
139 stdplus_fd_dep = stdplus_dep
140
141 import('pkgconfig').generate(
142 stdplus_lib,
143 name: 'stdplus-fd',
144 description: 'C++ helper utilities',
145 version: meson.project_version(),
146 requires: stdplus_reqs)
147endif
148
149if has_io_uring
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700150 stdplus_io_uring_deps = [
151 stdplus_dep,
152 stdplus_fd_dep,
153 io_uring_dep,
154 ]
155
156 stdplus_io_uring_pre = declare_dependency(
157 include_directories: stdplus_io_uring_headers,
158 dependencies: stdplus_io_uring_deps)
159
160 stdplus_io_uring_lib = library(
161 'stdplus-io_uring',
162 'io_uring.cpp',
163 dependencies: stdplus_io_uring_pre,
164 implicit_include_directories: false,
165 version: meson.project_version(),
166 install: true)
167
168 stdplus_io_uring_dep = declare_dependency(
169 dependencies: stdplus_io_uring_pre,
170 link_with: stdplus_io_uring_lib)
171
172 stdplus_io_uring_reqs = []
173 foreach dep : stdplus_io_uring_deps
174 if dep.type_name() == 'pkgconfig'
175 stdplus_io_uring_reqs += dep
176 endif
177 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700178
179 import('pkgconfig').generate(
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700180 stdplus_io_uring_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700181 description: 'C++ helper utilities',
182 version: meson.project_version(),
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700183 requires: stdplus_io_uring_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700184endif
William A. Kennington III953de362022-07-13 17:32:55 -0700185
186if has_gtest
187 stdplus_gtest_deps = [
188 fmt_dep,
189 gtest_dep,
190 ]
191
192 stdplus_gtest_pre = declare_dependency(
193 include_directories: stdplus_gtest_headers,
194 dependencies: stdplus_gtest_deps)
195
196 stdplus_gtest_lib = library(
197 'stdplus-gtest',
198 'gtest/tmp.cpp',
199 dependencies: stdplus_gtest_pre,
200 implicit_include_directories: false,
201 version: meson.project_version(),
202 install: true)
203
204 stdplus_gtest_dep = declare_dependency(
205 dependencies: stdplus_gtest_pre,
206 link_with: stdplus_gtest_lib)
207
208 stdplus_gtest_reqs = []
209 foreach dep : stdplus_gtest_deps
210 if dep.type_name() == 'pkgconfig'
211 stdplus_gtest_reqs += dep
212 endif
213 endforeach
214
215 import('pkgconfig').generate(
216 stdplus_gtest_lib,
217 description: 'C++ helper utilities',
218 version: meson.project_version(),
219 requires: stdplus_gtest_reqs)
William A. Kennington III2030ea52022-07-19 17:06:39 -0700220
221 install_data(
222 'run_with_tmp',
223 install_mode: 'rwxr-xr-x',
224 install_dir: get_option('bindir'))
225
226 meson.override_find_program('run_with_tmp', files('run_with_tmp'))
William A. Kennington III953de362022-07-13 17:32:55 -0700227endif
William A. Kennington III2030ea52022-07-19 17:06:39 -0700228
229run_with_tmp = find_program('run_with_tmp', native: true)