blob: bdb8f67d95ac739ccd763994606c2c1cf2228ebb [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 IIIe0990382019-10-18 02:10:25 -070016stdplus_deps = [
17 fmt_dep,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070018]
19
William A. Kennington III45754242021-04-28 12:48:31 -070020stdplus_srcs = [
William A. Kennington III7613a5e2022-07-13 16:25:00 -070021 'exception.cpp',
22 'signal.cpp',
William A. Kennington III61a81bc2022-09-19 17:46:49 -070023 'zstring_view.cpp',
William A. Kennington III45754242021-04-28 12:48:31 -070024]
25
William A. Kennington III7613a5e2022-07-13 16:25:00 -070026if has_fd
William A. Kennington III45754242021-04-28 12:48:31 -070027 stdplus_srcs += [
William A. Kennington IIIaa4fcfc2022-08-23 16:35:10 -070028 'fd/atomic.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070029 'fd/create.cpp',
30 'fd/dupable.cpp',
William A. Kennington III4f5711c2022-08-12 17:01:53 -070031 'fd/fmt.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070032 'fd/impl.cpp',
William A. Kennington III9a512c92022-08-12 15:15:55 -070033 'fd/line.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070034 'fd/managed.cpp',
35 'fd/mmap.cpp',
36 'fd/ops.cpp',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070037 ]
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070038endif
39
William A. Kennington III97e39472019-04-03 13:22:32 -070040stdplus_lib = library(
William A. Kennington III15982f62019-01-31 14:43:41 -080041 'stdplus',
William A. Kennington III45754242021-04-28 12:48:31 -070042 stdplus_srcs,
William A. Kennington III97e39472019-04-03 13:22:32 -070043 include_directories: stdplus_headers,
William A. Kennington III15982f62019-01-31 14:43:41 -080044 implicit_include_directories: false,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070045 dependencies: stdplus_deps,
William A. Kennington III1937ef62019-03-28 03:24:57 -070046 version: meson.project_version(),
William A. Kennington III15982f62019-01-31 14:43:41 -080047 install: true)
48
William A. Kennington III3acf92b2021-04-16 13:33:50 -070049stdplus_dep = declare_dependency(
William A. Kennington IIIe0990382019-10-18 02:10:25 -070050 dependencies: stdplus_deps,
William A. Kennington III97e39472019-04-03 13:22:32 -070051 include_directories: stdplus_headers,
52 link_with: stdplus_lib)
53
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070054stdplus_reqs = []
55foreach dep : stdplus_deps
56 if dep.type_name() == 'pkgconfig'
William A. Kennington III285fbcb2021-01-24 18:16:20 -080057 stdplus_reqs += dep
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070058 endif
59endforeach
60
William A. Kennington III15982f62019-01-31 14:43:41 -080061import('pkgconfig').generate(
William A. Kennington III285fbcb2021-01-24 18:16:20 -080062 stdplus_lib,
William A. Kennington III15982f62019-01-31 14:43:41 -080063 description: 'C++ helper utilities',
64 version: meson.project_version(),
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070065 requires: stdplus_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070066
67if has_dl
William A. Kennington III696fb6b2022-08-24 15:28:43 -070068 stdplus_dl_deps = [
69 stdplus_dep,
70 dl_dep,
71 ]
72
73 stdplus_dl_pre = declare_dependency(
74 include_directories: stdplus_dl_headers,
75 dependencies: stdplus_dl_deps)
76
77 stdplus_dl_lib = library(
78 'stdplus-dl',
79 'dl.cpp',
80 dependencies: stdplus_dl_pre,
81 implicit_include_directories: false,
82 version: meson.project_version(),
83 install: true)
84
85 stdplus_dl_dep = declare_dependency(
86 dependencies: stdplus_dl_pre,
87 link_with: stdplus_dl_lib)
88
89 stdplus_dl_reqs = []
90 foreach dep : stdplus_dl_deps
91 if dep.type_name() == 'pkgconfig'
92 stdplus_dl_reqs += dep
93 endif
94 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070095
96 import('pkgconfig').generate(
William A. Kennington III696fb6b2022-08-24 15:28:43 -070097 stdplus_dl_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070098 description: 'C++ helper utilities',
99 version: meson.project_version(),
William A. Kennington III696fb6b2022-08-24 15:28:43 -0700100 requires: stdplus_dl_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700101endif
102
103if has_fd
104 stdplus_fd_dep = stdplus_dep
105
106 import('pkgconfig').generate(
107 stdplus_lib,
108 name: 'stdplus-fd',
109 description: 'C++ helper utilities',
110 version: meson.project_version(),
111 requires: stdplus_reqs)
112endif
113
114if has_io_uring
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700115 stdplus_io_uring_deps = [
116 stdplus_dep,
117 stdplus_fd_dep,
118 io_uring_dep,
119 ]
120
121 stdplus_io_uring_pre = declare_dependency(
122 include_directories: stdplus_io_uring_headers,
123 dependencies: stdplus_io_uring_deps)
124
125 stdplus_io_uring_lib = library(
126 'stdplus-io_uring',
127 'io_uring.cpp',
128 dependencies: stdplus_io_uring_pre,
129 implicit_include_directories: false,
130 version: meson.project_version(),
131 install: true)
132
133 stdplus_io_uring_dep = declare_dependency(
134 dependencies: stdplus_io_uring_pre,
135 link_with: stdplus_io_uring_lib)
136
137 stdplus_io_uring_reqs = []
138 foreach dep : stdplus_io_uring_deps
139 if dep.type_name() == 'pkgconfig'
140 stdplus_io_uring_reqs += dep
141 endif
142 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700143
144 import('pkgconfig').generate(
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700145 stdplus_io_uring_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700146 description: 'C++ helper utilities',
147 version: meson.project_version(),
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700148 requires: stdplus_io_uring_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700149endif
William A. Kennington III953de362022-07-13 17:32:55 -0700150
151if has_gtest
152 stdplus_gtest_deps = [
153 fmt_dep,
154 gtest_dep,
155 ]
156
157 stdplus_gtest_pre = declare_dependency(
158 include_directories: stdplus_gtest_headers,
159 dependencies: stdplus_gtest_deps)
160
161 stdplus_gtest_lib = library(
162 'stdplus-gtest',
163 'gtest/tmp.cpp',
164 dependencies: stdplus_gtest_pre,
165 implicit_include_directories: false,
166 version: meson.project_version(),
167 install: true)
168
169 stdplus_gtest_dep = declare_dependency(
170 dependencies: stdplus_gtest_pre,
171 link_with: stdplus_gtest_lib)
172
173 stdplus_gtest_reqs = []
174 foreach dep : stdplus_gtest_deps
175 if dep.type_name() == 'pkgconfig'
176 stdplus_gtest_reqs += dep
177 endif
178 endforeach
179
180 import('pkgconfig').generate(
181 stdplus_gtest_lib,
182 description: 'C++ helper utilities',
183 version: meson.project_version(),
184 requires: stdplus_gtest_reqs)
William A. Kennington III2030ea52022-07-19 17:06:39 -0700185
186 install_data(
187 'run_with_tmp',
188 install_mode: 'rwxr-xr-x',
189 install_dir: get_option('bindir'))
190
191 meson.override_find_program('run_with_tmp', files('run_with_tmp'))
William A. Kennington III953de362022-07-13 17:32:55 -0700192endif
William A. Kennington III2030ea52022-07-19 17:06:39 -0700193
194run_with_tmp = find_program('run_with_tmp', native: true)