blob: 2a0169a70a0745a4738a8a7f11d1b804effbbb77 [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
18# span-lite might not have a pkg-config. It is header only so just make
19# sure we can access the needed symbols from the header.
William A. Kennington IIIf65edcb2021-01-30 15:45:35 -080020span_dep = dependency('span-lite', required: false)
William A. Kennington IIIe0990382019-10-18 02:10:25 -070021has_span = meson.get_compiler('cpp').has_header_symbol(
William A. Kennington IIIf65edcb2021-01-30 15:45:35 -080022 'nonstd/span.hpp',
William A. Kennington IIIaf0e0e82021-05-15 00:57:23 -070023 'nonstd::span<int>',
William A. Kennington IIIe0990382019-10-18 02:10:25 -070024 dependencies: span_dep,
25 required: false)
26if not has_span
William A. Kennington IIIf65edcb2021-01-30 15:45:35 -080027 span_lite_proj = import('cmake').subproject(
28 'span-lite',
William A. Kennington IIIe0990382019-10-18 02:10:25 -070029 required: false)
William A. Kennington IIIf65edcb2021-01-30 15:45:35 -080030 if span_lite_proj.found()
31 span_dep = span_lite_proj.dependency('span-lite')
32 has_span = true
William A. Kennington IIIe0990382019-10-18 02:10:25 -070033 endif
34endif
35
36stdplus_deps = [
37 fmt_dep,
38 span_dep,
39]
40
William A. Kennington III45754242021-04-28 12:48:31 -070041stdplus_srcs = [
42 'stdplus/exception.cpp',
43 'stdplus/signal.cpp',
44]
45
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070046has_fd = false
47if not get_option('fd').disabled() and has_span
48 has_fd = true
49
William A. Kennington III45754242021-04-28 12:48:31 -070050 stdplus_srcs += [
William A. Kennington IIIeac9d472020-08-03 13:57:14 -070051 'stdplus/fd/create.cpp',
52 'stdplus/fd/dupable.cpp',
53 'stdplus/fd/impl.cpp',
54 'stdplus/fd/managed.cpp',
55 'stdplus/fd/ops.cpp',
56 ]
57
58 install_headers(
59 'stdplus/fd/create.hpp',
60 'stdplus/fd/dupable.hpp',
61 'stdplus/fd/gmock.hpp',
62 'stdplus/fd/impl.hpp',
63 'stdplus/fd/intf.hpp',
64 'stdplus/fd/managed.hpp',
65 'stdplus/fd/ops.hpp',
66 subdir: 'stdplus/fd')
67elif get_option('fd').enabled()
68 error('File descriptor support required')
69endif
70
William A. Kennington III5c20da22021-06-18 16:44:55 -070071io_uring_dep = dependency('liburing', required: get_option('io_uring'))
72has_io_uring = false
73if not get_option('io_uring').disabled() and has_fd and io_uring_dep.found()
74 has_io_uring = true
75
76 stdplus_deps += [
77 io_uring_dep,
78 ]
79
80 stdplus_srcs += [
81 'stdplus/io_uring.cpp',
82 ]
83
84 install_headers(
85 'stdplus/io_uring.hpp',
86 subdir: 'stdplus')
87elif get_option('io_uring').enabled()
88 error('File descriptor support required')
89endif
90
William A. Kennington III97e39472019-04-03 13:22:32 -070091stdplus_lib = library(
William A. Kennington III15982f62019-01-31 14:43:41 -080092 'stdplus',
William A. Kennington III45754242021-04-28 12:48:31 -070093 stdplus_srcs,
William A. Kennington III97e39472019-04-03 13:22:32 -070094 include_directories: stdplus_headers,
William A. Kennington III15982f62019-01-31 14:43:41 -080095 implicit_include_directories: false,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070096 dependencies: stdplus_deps,
William A. Kennington III1937ef62019-03-28 03:24:57 -070097 version: meson.project_version(),
William A. Kennington III15982f62019-01-31 14:43:41 -080098 install: true)
99
William A. Kennington III3acf92b2021-04-16 13:33:50 -0700100stdplus_dep = declare_dependency(
William A. Kennington IIIe0990382019-10-18 02:10:25 -0700101 dependencies: stdplus_deps,
William A. Kennington III97e39472019-04-03 13:22:32 -0700102 include_directories: stdplus_headers,
103 link_with: stdplus_lib)
104
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700105stdplus_reqs = []
106foreach dep : stdplus_deps
107 if dep.type_name() == 'pkgconfig'
William A. Kennington III285fbcb2021-01-24 18:16:20 -0800108 stdplus_reqs += dep
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700109 endif
110endforeach
111
William A. Kennington III15982f62019-01-31 14:43:41 -0800112import('pkgconfig').generate(
William A. Kennington III285fbcb2021-01-24 18:16:20 -0800113 stdplus_lib,
William A. Kennington III15982f62019-01-31 14:43:41 -0800114 description: 'C++ helper utilities',
115 version: meson.project_version(),
William A. Kennington IIIb01c5572020-06-03 19:40:49 -0700116 requires: stdplus_reqs)
William A. Kennington III15982f62019-01-31 14:43:41 -0800117
118install_headers(
William A. Kennington III458aeae2021-06-14 15:07:16 -0700119 'stdplus/cancel.hpp',
William A. Kennington III2f210732020-08-02 16:12:36 -0700120 'stdplus/exception.hpp',
William A. Kennington IIIeac9d472020-08-03 13:57:14 -0700121 'stdplus/flags.hpp',
William A. Kennington IIIe0990382019-10-18 02:10:25 -0700122 'stdplus/raw.hpp',
William A. Kennington III15982f62019-01-31 14:43:41 -0800123 'stdplus/signal.hpp',
William A. Kennington IIIda284aa2020-06-03 19:41:10 -0700124 'stdplus/types.hpp',
William A. Kennington III15982f62019-01-31 14:43:41 -0800125 subdir: 'stdplus')
William A. Kennington III7a5e2322018-11-02 17:28:35 -0700126
127install_headers(
William A. Kennington IIIe847ef82018-11-02 17:29:15 -0700128 'stdplus/handle/copyable.hpp',
William A. Kennington III7a5e2322018-11-02 17:28:35 -0700129 'stdplus/handle/managed.hpp',
130 subdir: 'stdplus/handle')
William A. Kennington IIIbff0b0f2018-11-16 19:56:10 -0800131
132install_headers(
133 'stdplus/util/cexec.hpp',
William A. Kennington III4ef36e72019-06-27 12:48:59 -0700134 'stdplus/util/string.hpp',
William A. Kennington IIIbff0b0f2018-11-16 19:56:10 -0800135 subdir: 'stdplus/util')