blob: 436439577f59d7ead73c61fc7b21f55cffc05529 [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 III45754242021-04-28 12:48:31 -070023]
24
William A. Kennington III5a528022021-04-28 12:52:43 -070025if has_dl
26 stdplus_deps += [
27 dl_dep,
28 ]
29
30 stdplus_srcs += [
William A. Kennington III7613a5e2022-07-13 16:25:00 -070031 'dl.cpp',
William A. Kennington III5a528022021-04-28 12:52:43 -070032 ]
William A. Kennington III5a528022021-04-28 12:52:43 -070033endif
34
William A. Kennington III7613a5e2022-07-13 16:25:00 -070035if has_fd
William A. Kennington III45754242021-04-28 12:48:31 -070036 stdplus_srcs += [
William A. Kennington III7613a5e2022-07-13 16:25:00 -070037 'fd/create.cpp',
38 'fd/dupable.cpp',
39 'fd/impl.cpp',
William A. Kennington III9a512c92022-08-12 15:15:55 -070040 'fd/line.cpp',
William A. Kennington III7613a5e2022-07-13 16:25:00 -070041 'fd/managed.cpp',
42 'fd/mmap.cpp',
43 'fd/ops.cpp',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070044 ]
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070045endif
46
William A. Kennington III97e39472019-04-03 13:22:32 -070047stdplus_lib = library(
William A. Kennington III15982f62019-01-31 14:43:41 -080048 'stdplus',
William A. Kennington III45754242021-04-28 12:48:31 -070049 stdplus_srcs,
William A. Kennington III97e39472019-04-03 13:22:32 -070050 include_directories: stdplus_headers,
William A. Kennington III15982f62019-01-31 14:43:41 -080051 implicit_include_directories: false,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070052 dependencies: stdplus_deps,
William A. Kennington III1937ef62019-03-28 03:24:57 -070053 version: meson.project_version(),
William A. Kennington III15982f62019-01-31 14:43:41 -080054 install: true)
55
William A. Kennington III3acf92b2021-04-16 13:33:50 -070056stdplus_dep = declare_dependency(
William A. Kennington IIIe0990382019-10-18 02:10:25 -070057 dependencies: stdplus_deps,
William A. Kennington III97e39472019-04-03 13:22:32 -070058 include_directories: stdplus_headers,
59 link_with: stdplus_lib)
60
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070061stdplus_reqs = []
62foreach dep : stdplus_deps
63 if dep.type_name() == 'pkgconfig'
William A. Kennington III285fbcb2021-01-24 18:16:20 -080064 stdplus_reqs += dep
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070065 endif
66endforeach
67
William A. Kennington III15982f62019-01-31 14:43:41 -080068import('pkgconfig').generate(
William A. Kennington III285fbcb2021-01-24 18:16:20 -080069 stdplus_lib,
William A. Kennington III15982f62019-01-31 14:43:41 -080070 description: 'C++ helper utilities',
71 version: meson.project_version(),
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070072 requires: stdplus_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -070073
74if has_dl
75 stdplus_dl_dep = stdplus_dep
76
77 import('pkgconfig').generate(
78 stdplus_lib,
79 name: 'stdplus-dl',
80 description: 'C++ helper utilities',
81 version: meson.project_version(),
82 requires: stdplus_reqs)
83endif
84
85if has_fd
86 stdplus_fd_dep = stdplus_dep
87
88 import('pkgconfig').generate(
89 stdplus_lib,
90 name: 'stdplus-fd',
91 description: 'C++ helper utilities',
92 version: meson.project_version(),
93 requires: stdplus_reqs)
94endif
95
96if has_io_uring
William A. Kennington IIIee53ad32022-07-14 16:14:31 -070097 stdplus_io_uring_deps = [
98 stdplus_dep,
99 stdplus_fd_dep,
100 io_uring_dep,
101 ]
102
103 stdplus_io_uring_pre = declare_dependency(
104 include_directories: stdplus_io_uring_headers,
105 dependencies: stdplus_io_uring_deps)
106
107 stdplus_io_uring_lib = library(
108 'stdplus-io_uring',
109 'io_uring.cpp',
110 dependencies: stdplus_io_uring_pre,
111 implicit_include_directories: false,
112 version: meson.project_version(),
113 install: true)
114
115 stdplus_io_uring_dep = declare_dependency(
116 dependencies: stdplus_io_uring_pre,
117 link_with: stdplus_io_uring_lib)
118
119 stdplus_io_uring_reqs = []
120 foreach dep : stdplus_io_uring_deps
121 if dep.type_name() == 'pkgconfig'
122 stdplus_io_uring_reqs += dep
123 endif
124 endforeach
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700125
126 import('pkgconfig').generate(
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700127 stdplus_io_uring_lib,
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700128 description: 'C++ helper utilities',
129 version: meson.project_version(),
William A. Kennington IIIee53ad32022-07-14 16:14:31 -0700130 requires: stdplus_io_uring_reqs)
William A. Kennington IIId7acddd2022-07-13 16:41:11 -0700131endif
William A. Kennington III953de362022-07-13 17:32:55 -0700132
133if has_gtest
134 stdplus_gtest_deps = [
135 fmt_dep,
136 gtest_dep,
137 ]
138
139 stdplus_gtest_pre = declare_dependency(
140 include_directories: stdplus_gtest_headers,
141 dependencies: stdplus_gtest_deps)
142
143 stdplus_gtest_lib = library(
144 'stdplus-gtest',
145 'gtest/tmp.cpp',
146 dependencies: stdplus_gtest_pre,
147 implicit_include_directories: false,
148 version: meson.project_version(),
149 install: true)
150
151 stdplus_gtest_dep = declare_dependency(
152 dependencies: stdplus_gtest_pre,
153 link_with: stdplus_gtest_lib)
154
155 stdplus_gtest_reqs = []
156 foreach dep : stdplus_gtest_deps
157 if dep.type_name() == 'pkgconfig'
158 stdplus_gtest_reqs += dep
159 endif
160 endforeach
161
162 import('pkgconfig').generate(
163 stdplus_gtest_lib,
164 description: 'C++ helper utilities',
165 version: meson.project_version(),
166 requires: stdplus_gtest_reqs)
William A. Kennington III2030ea52022-07-19 17:06:39 -0700167
168 install_data(
169 'run_with_tmp',
170 install_mode: 'rwxr-xr-x',
171 install_dir: get_option('bindir'))
172
173 meson.override_find_program('run_with_tmp', files('run_with_tmp'))
William A. Kennington III953de362022-07-13 17:32:55 -0700174endif
William A. Kennington III2030ea52022-07-19 17:06:39 -0700175
176run_with_tmp = find_program('run_with_tmp', native: true)