blob: 204110f582e608b2a65a00e3f1a467c07b1bf7a1 [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 III7613a5e2022-07-13 16:25:00 -070045 'exception.cpp',
46 'signal.cpp',
William A. Kennington IIIf2ddf512022-09-20 15:36:44 -070047 'zstring.cpp',
William A. Kennington III61a81bc2022-09-19 17:46:49 -070048 'zstring_view.cpp',
William A. Kennington III45754242021-04-28 12:48:31 -070049]
50
William A. Kennington III7613a5e2022-07-13 16:25:00 -070051if has_fd
William A. Kennington III45754242021-04-28 12:48:31 -070052 stdplus_srcs += [
William A. Kennington IIIaa4fcfc2022-08-23 16:35:10 -070053 'fd/atomic.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070054 'fd/create.cpp',
55 'fd/dupable.cpp',
William A. Kennington III4f5711c2022-08-12 17:01:53 -070056 'fd/fmt.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070057 'fd/impl.cpp',
William A. Kennington III9a512c92022-08-12 15:15:55 -070058 'fd/line.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070059 'fd/managed.cpp',
60 'fd/mmap.cpp',
61 'fd/ops.cpp',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070062 ]
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070063endif
64
William A. Kennington III97e39472019-04-03 13:22:32 -070065stdplus_lib = library(
William A. Kennington III15982f62019-01-31 14:43:41 -080066 'stdplus',
William A. Kennington III45754242021-04-28 12:48:31 -070067 stdplus_srcs,
William A. Kennington III97e39472019-04-03 13:22:32 -070068 include_directories: stdplus_headers,
William A. Kennington III15982f62019-01-31 14:43:41 -080069 implicit_include_directories: false,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070070 dependencies: stdplus_deps,
William A. Kennington III1937ef62019-03-28 03:24:57 -070071 version: meson.project_version(),
William A. Kennington III15982f62019-01-31 14:43:41 -080072 install: true)
73
William A. Kennington III3acf92b2021-04-16 13:33:50 -070074stdplus_dep = declare_dependency(
William A. Kennington IIIe0990382019-10-18 02:10:25 -070075 dependencies: stdplus_deps,
William A. Kennington III97e39472019-04-03 13:22:32 -070076 include_directories: stdplus_headers,
77 link_with: stdplus_lib)
78
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070079stdplus_reqs = []
80foreach dep : stdplus_deps
81 if dep.type_name() == 'pkgconfig'
William A. Kennington III285fbcb2021-01-24 18:16:20 -080082 stdplus_reqs += dep
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070083 endif
84endforeach
85
William A. Kennington III15982f62019-01-31 14:43:41 -080086import('pkgconfig').generate(
William A. Kennington III285fbcb2021-01-24 18:16:20 -080087 stdplus_lib,
William A. Kennington III15982f62019-01-31 14:43:41 -080088 description: 'C++ helper utilities',
89 version: meson.project_version(),
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070090 requires: stdplus_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070091
92if has_dl
William A. Kennington III696fb6b2022-08-24 15:28:43 -070093 stdplus_dl_deps = [
94 stdplus_dep,
95 dl_dep,
96 ]
97
98 stdplus_dl_pre = declare_dependency(
99 include_directories: stdplus_dl_headers,
100 dependencies: stdplus_dl_deps)
101
102 stdplus_dl_lib = library(
103 'stdplus-dl',
104 'dl.cpp',
105 dependencies: stdplus_dl_pre,
106 implicit_include_directories: false,
107 version: meson.project_version(),
108 install: true)
109
110 stdplus_dl_dep = declare_dependency(
111 dependencies: stdplus_dl_pre,
112 link_with: stdplus_dl_lib)
113
114 stdplus_dl_reqs = []
115 foreach dep : stdplus_dl_deps
116 if dep.type_name() == 'pkgconfig'
117 stdplus_dl_reqs += dep
118 endif
119 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700120
121 import('pkgconfig').generate(
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700122 stdplus_dl_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700123 description: 'C++ helper utilities',
124 version: meson.project_version(),
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700125 requires: stdplus_dl_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700126endif
127
128if has_fd
129 stdplus_fd_dep = stdplus_dep
130
131 import('pkgconfig').generate(
132 stdplus_lib,
133 name: 'stdplus-fd',
134 description: 'C++ helper utilities',
135 version: meson.project_version(),
136 requires: stdplus_reqs)
137endif
138
139if has_io_uring
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700140 stdplus_io_uring_deps = [
141 stdplus_dep,
142 stdplus_fd_dep,
143 io_uring_dep,
144 ]
145
146 stdplus_io_uring_pre = declare_dependency(
147 include_directories: stdplus_io_uring_headers,
148 dependencies: stdplus_io_uring_deps)
149
150 stdplus_io_uring_lib = library(
151 'stdplus-io_uring',
152 'io_uring.cpp',
153 dependencies: stdplus_io_uring_pre,
154 implicit_include_directories: false,
155 version: meson.project_version(),
156 install: true)
157
158 stdplus_io_uring_dep = declare_dependency(
159 dependencies: stdplus_io_uring_pre,
160 link_with: stdplus_io_uring_lib)
161
162 stdplus_io_uring_reqs = []
163 foreach dep : stdplus_io_uring_deps
164 if dep.type_name() == 'pkgconfig'
165 stdplus_io_uring_reqs += dep
166 endif
167 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700168
169 import('pkgconfig').generate(
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700170 stdplus_io_uring_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700171 description: 'C++ helper utilities',
172 version: meson.project_version(),
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700173 requires: stdplus_io_uring_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700174endif
William A. Kennington III953de362022-07-13 17:32:55 -0700175
176if has_gtest
177 stdplus_gtest_deps = [
178 fmt_dep,
179 gtest_dep,
180 ]
181
182 stdplus_gtest_pre = declare_dependency(
183 include_directories: stdplus_gtest_headers,
184 dependencies: stdplus_gtest_deps)
185
186 stdplus_gtest_lib = library(
187 'stdplus-gtest',
188 'gtest/tmp.cpp',
189 dependencies: stdplus_gtest_pre,
190 implicit_include_directories: false,
191 version: meson.project_version(),
192 install: true)
193
194 stdplus_gtest_dep = declare_dependency(
195 dependencies: stdplus_gtest_pre,
196 link_with: stdplus_gtest_lib)
197
198 stdplus_gtest_reqs = []
199 foreach dep : stdplus_gtest_deps
200 if dep.type_name() == 'pkgconfig'
201 stdplus_gtest_reqs += dep
202 endif
203 endforeach
204
205 import('pkgconfig').generate(
206 stdplus_gtest_lib,
207 description: 'C++ helper utilities',
208 version: meson.project_version(),
209 requires: stdplus_gtest_reqs)
William A. Kennington III2030ea52022-07-19 17:06:39 -0700210
211 install_data(
212 'run_with_tmp',
213 install_mode: 'rwxr-xr-x',
214 install_dir: get_option('bindir'))
215
216 meson.override_find_program('run_with_tmp', files('run_with_tmp'))
William A. Kennington III953de362022-07-13 17:32:55 -0700217endif
William A. Kennington III2030ea52022-07-19 17:06:39 -0700218
219run_with_tmp = find_program('run_with_tmp', native: true)