blob: af7399c8a4600dcfbc7d3b858641c2adb7a55ce8 [file] [log] [blame]
William A. Kennington III97e39472019-04-03 13:22:32 -07001stdplus_headers = include_directories('.')
2
William A. Kennington IIIe0990382019-10-18 02:10:25 -07003fmt_dep = dependency('fmt', required: false)
William A. Kennington IIIe0990382019-10-18 02:10:25 -07004if not fmt_dep.found()
William A. Kennington IIIb5d1c582021-04-16 13:41:39 -07005 fmt_opts = import('cmake').subproject_options()
6 fmt_opts.add_cmake_defines({
7 'CMAKE_POSITION_INDEPENDENT_CODE': 'ON',
8 'MASTER_PROJECT': 'OFF',
9 })
William A. Kennington IIIe0990382019-10-18 02:10:25 -070010 fmt_proj = import('cmake').subproject(
11 'fmt',
William A. Kennington IIIb5d1c582021-04-16 13:41:39 -070012 options: fmt_opts,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070013 required: false)
14 assert(fmt_proj.found(), 'fmtlib is required')
15 fmt_dep = fmt_proj.dependency('fmt')
16endif
17
William A. Kennington IIIe0990382019-10-18 02:10:25 -070018stdplus_deps = [
19 fmt_dep,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070020]
21
William A. Kennington III45754242021-04-28 12:48:31 -070022stdplus_srcs = [
23 'stdplus/exception.cpp',
24 'stdplus/signal.cpp',
25]
26
William A. Kennington III5a528022021-04-28 12:52:43 -070027has_dl = false
28if not get_option('dl').disabled()
29 dl_dep = meson.get_compiler('cpp').find_library('dl', required: false)
William A. Kennington III8b70ecc2021-10-28 21:13:14 -070030 has_dl = meson.get_compiler('cpp').links('''
William A. Kennington III5a528022021-04-28 12:52:43 -070031 #include <dlfcn.h>
32 int main() { dlopen("", 0); }
William A. Kennington III8b70ecc2021-10-28 21:13:14 -070033 ''', dependencies: dl_dep)
William A. Kennington III5a528022021-04-28 12:52:43 -070034endif
35if has_dl
36 stdplus_deps += [
37 dl_dep,
38 ]
39
40 stdplus_srcs += [
41 'stdplus/dl.cpp',
42 ]
43
44 install_headers(
45 'stdplus/dl.hpp',
46 subdir: 'stdplus')
47elif get_option('dl').enabled()
48 error('libdl support required')
49endif
50
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070051has_fd = false
Patrick Williams68975b92022-04-27 16:00:26 -050052if not get_option('fd').disabled()
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070053 has_fd = true
54
William A. Kennington III45754242021-04-28 12:48:31 -070055 stdplus_srcs += [
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070056 'stdplus/fd/create.cpp',
57 'stdplus/fd/dupable.cpp',
58 'stdplus/fd/impl.cpp',
59 'stdplus/fd/managed.cpp',
William A. Kennington III891e6a32022-05-17 16:35:03 -070060 'stdplus/fd/mmap.cpp',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070061 'stdplus/fd/ops.cpp',
62 ]
63
64 install_headers(
65 'stdplus/fd/create.hpp',
66 'stdplus/fd/dupable.hpp',
67 'stdplus/fd/gmock.hpp',
68 'stdplus/fd/impl.hpp',
69 'stdplus/fd/intf.hpp',
70 'stdplus/fd/managed.hpp',
William A. Kennington III891e6a32022-05-17 16:35:03 -070071 'stdplus/fd/mmap.hpp',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070072 'stdplus/fd/ops.hpp',
73 subdir: 'stdplus/fd')
74elif get_option('fd').enabled()
75 error('File descriptor support required')
76endif
77
William A. Kennington III5c20da22021-06-18 16:44:55 -070078io_uring_dep = dependency('liburing', required: get_option('io_uring'))
79has_io_uring = false
80if not get_option('io_uring').disabled() and has_fd and io_uring_dep.found()
81 has_io_uring = true
82
83 stdplus_deps += [
84 io_uring_dep,
85 ]
86
87 stdplus_srcs += [
88 'stdplus/io_uring.cpp',
89 ]
90
91 install_headers(
92 'stdplus/io_uring.hpp',
93 subdir: 'stdplus')
94elif get_option('io_uring').enabled()
95 error('File descriptor support required')
96endif
97
William A. Kennington III97e39472019-04-03 13:22:32 -070098stdplus_lib = library(
William A. Kennington III15982f62019-01-31 14:43:41 -080099 'stdplus',
William A. Kennington III45754242021-04-28 12:48:31 -0700100 stdplus_srcs,
William A. Kennington III97e39472019-04-03 13:22:32 -0700101 include_directories: stdplus_headers,
William A. Kennington III15982f62019-01-31 14:43:41 -0800102 implicit_include_directories: false,
William A. Kennington IIIe0990382019-10-18 02:10:25 -0700103 dependencies: stdplus_deps,
William A. Kennington III1937ef62019-03-28 03:24:57 -0700104 version: meson.project_version(),
William A. Kennington III15982f62019-01-31 14:43:41 -0800105 install: true)
106
William A. Kennington III3acf92b2021-04-16 13:33:50 -0700107stdplus_dep = declare_dependency(
William A. Kennington IIIe0990382019-10-18 02:10:25 -0700108 dependencies: stdplus_deps,
William A. Kennington III97e39472019-04-03 13:22:32 -0700109 include_directories: stdplus_headers,
110 link_with: stdplus_lib)
111
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700112stdplus_reqs = []
113foreach dep : stdplus_deps
114 if dep.type_name() == 'pkgconfig'
William A. Kennington III285fbcb2021-01-24 18:16:20 -0800115 stdplus_reqs += dep
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700116 endif
117endforeach
118
William A. Kennington III15982f62019-01-31 14:43:41 -0800119import('pkgconfig').generate(
William A. Kennington III285fbcb2021-01-24 18:16:20 -0800120 stdplus_lib,
William A. Kennington III15982f62019-01-31 14:43:41 -0800121 description: 'C++ helper utilities',
122 version: meson.project_version(),
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700123 requires: stdplus_reqs)
William A. Kennington III15982f62019-01-31 14:43:41 -0800124
125install_headers(
William A. Kennington III458aeae2021-06-14 15:07:16 -0700126 'stdplus/cancel.hpp',
William A. Kennington III2f210732020-08-02 16:12:36 -0700127 'stdplus/exception.hpp',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -0700128 'stdplus/flags.hpp',
William A. Kennington IIIe0990382019-10-18 02:10:25 -0700129 'stdplus/raw.hpp',
William A. Kennington III15982f62019-01-31 14:43:41 -0800130 'stdplus/signal.hpp',
131 subdir: 'stdplus')
William A. Kennington III7a5e2322018-11-02 17:28:35 -0700132
133install_headers(
William A. Kennington IIIe847ef82018-11-02 17:29:15 -0700134 'stdplus/handle/copyable.hpp',
William A. Kennington III7a5e2322018-11-02 17:28:35 -0700135 'stdplus/handle/managed.hpp',
136 subdir: 'stdplus/handle')
William A. Kennington IIIbff0b0f2018-11-16 19:56:10 -0800137
138install_headers(
139 'stdplus/util/cexec.hpp',
William A. Kennington III4ef36e72019-06-27 12:48:59 -0700140 'stdplus/util/string.hpp',
William A. Kennington IIIbff0b0f2018-11-16 19:56:10 -0800141 subdir: 'stdplus/util')