William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 1 | fmt_dep = dependency('fmt', required: false) |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 2 | if not fmt_dep.found() |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 3 | fmt_opts = import('cmake').subproject_options() |
| 4 | fmt_opts.add_cmake_defines( |
| 5 | {'CMAKE_POSITION_INDEPENDENT_CODE': 'ON', 'MASTER_PROJECT': 'OFF'}, |
| 6 | ) |
| 7 | fmt_proj = import('cmake').subproject( |
| 8 | 'fmt', |
| 9 | options: fmt_opts, |
| 10 | required: false, |
| 11 | ) |
| 12 | assert(fmt_proj.found(), 'fmtlib is required') |
| 13 | fmt_dep = fmt_proj.dependency('fmt') |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 14 | endif |
| 15 | |
William A. Kennington III | 08d8443 | 2022-09-21 10:57:58 -0700 | [diff] [blame] | 16 | # 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. |
| 18 | function2_dep = dependency('function2', required: false) |
| 19 | has_function2 = meson.get_compiler('cpp').has_header_symbol( |
| 20 | 'function2/function2.hpp', |
| 21 | 'fu2::unique_function', |
| 22 | dependencies: function2_dep, |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 23 | required: false, |
William A. Kennington III | 08d8443 | 2022-09-21 10:57:58 -0700 | [diff] [blame] | 24 | ) |
| 25 | if 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, |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 31 | required: false, |
William A. Kennington III | 08d8443 | 2022-09-21 10:57:58 -0700 | [diff] [blame] | 32 | ) |
| 33 | assert(function2_proj.found(), 'function2 is required') |
| 34 | if function2_proj.found() |
| 35 | function2_dep = function2_proj.dependency('function2') |
| 36 | endif |
| 37 | endif |
| 38 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 39 | stdplus_deps = [fmt_dep, function2_dep] |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 40 | |
William A. Kennington III | 4575424 | 2021-04-28 12:48:31 -0700 | [diff] [blame] | 41 | stdplus_srcs = [ |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 42 | 'cancel.cpp', |
| 43 | 'debug/lifetime.cpp', |
| 44 | 'exception.cpp', |
| 45 | 'flags.cpp', |
| 46 | 'function_view.cpp', |
| 47 | 'handle/copyable.cpp', |
| 48 | 'handle/managed.cpp', |
| 49 | 'hash.cpp', |
| 50 | 'hash/array.cpp', |
| 51 | 'hash/tuple.cpp', |
| 52 | 'net/addr/ether.cpp', |
| 53 | 'net/addr/ip.cpp', |
| 54 | 'net/addr/sock.cpp', |
| 55 | 'net/addr/subnet.cpp', |
| 56 | 'numeric/endian.cpp', |
| 57 | 'numeric/str.cpp', |
| 58 | 'pinned.cpp', |
| 59 | 'print.cpp', |
| 60 | 'raw.cpp', |
| 61 | 'signal.cpp', |
| 62 | 'str/buf.cpp', |
| 63 | 'str/cat.cpp', |
| 64 | 'str/cexpr.cpp', |
| 65 | 'str/conv.cpp', |
| 66 | 'str/maps.cpp', |
| 67 | 'util/cexec.cpp', |
| 68 | 'variant.cpp', |
| 69 | 'zstring.cpp', |
| 70 | 'zstring_view.cpp', |
William A. Kennington III | 4575424 | 2021-04-28 12:48:31 -0700 | [diff] [blame] | 71 | ] |
| 72 | |
William A. Kennington III | 7613a5e | 2022-07-13 16:25:00 -0700 | [diff] [blame] | 73 | if has_fd |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 74 | stdplus_srcs += [ |
| 75 | 'fd/atomic.cpp', |
| 76 | 'fd/create.cpp', |
| 77 | 'fd/dupable.cpp', |
| 78 | 'fd/fmt.cpp', |
| 79 | 'fd/impl.cpp', |
| 80 | 'fd/line.cpp', |
| 81 | 'fd/managed.cpp', |
| 82 | 'fd/mmap.cpp', |
| 83 | 'fd/ops.cpp', |
| 84 | ] |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 85 | endif |
| 86 | |
William A. Kennington III | 97e3947 | 2019-04-03 13:22:32 -0700 | [diff] [blame] | 87 | stdplus_lib = library( |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 88 | 'stdplus', |
| 89 | stdplus_srcs, |
| 90 | include_directories: stdplus_headers, |
| 91 | implicit_include_directories: false, |
| 92 | dependencies: stdplus_deps, |
| 93 | version: meson.project_version(), |
| 94 | build_by_default: not meson.is_subproject(), |
| 95 | install: true, |
| 96 | ) |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 97 | |
William A. Kennington III | 3acf92b | 2021-04-16 13:33:50 -0700 | [diff] [blame] | 98 | stdplus_dep = declare_dependency( |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 99 | dependencies: stdplus_deps, |
| 100 | include_directories: stdplus_headers, |
| 101 | link_with: stdplus_lib, |
| 102 | ) |
William A. Kennington III | 97e3947 | 2019-04-03 13:22:32 -0700 | [diff] [blame] | 103 | |
William A. Kennington III | b01c557 | 2020-06-03 19:40:49 -0700 | [diff] [blame] | 104 | stdplus_reqs = [] |
| 105 | foreach dep : stdplus_deps |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 106 | if dep.type_name() == 'pkgconfig' |
| 107 | stdplus_reqs += dep |
| 108 | endif |
William A. Kennington III | b01c557 | 2020-06-03 19:40:49 -0700 | [diff] [blame] | 109 | endforeach |
| 110 | |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 111 | import('pkgconfig').generate( |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 112 | stdplus_lib, |
William A. Kennington III | d7acddd | 2022-07-13 16:41:11 -0700 | [diff] [blame] | 113 | description: 'C++ helper utilities', |
| 114 | version: meson.project_version(), |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 115 | requires: stdplus_reqs, |
| 116 | ) |
| 117 | |
| 118 | if has_dl |
| 119 | stdplus_dl_deps = [stdplus_dep, dl_dep] |
| 120 | |
| 121 | stdplus_dl_pre = declare_dependency( |
| 122 | include_directories: stdplus_dl_headers, |
| 123 | dependencies: stdplus_dl_deps, |
| 124 | ) |
| 125 | |
| 126 | stdplus_dl_lib = library( |
| 127 | 'stdplus-dl', |
| 128 | 'dl.cpp', |
| 129 | dependencies: stdplus_dl_pre, |
| 130 | implicit_include_directories: false, |
| 131 | version: meson.project_version(), |
| 132 | build_by_default: not meson.is_subproject(), |
| 133 | install: true, |
| 134 | ) |
| 135 | |
| 136 | stdplus_dl_dep = declare_dependency( |
| 137 | dependencies: stdplus_dl_pre, |
| 138 | link_with: stdplus_dl_lib, |
| 139 | ) |
| 140 | |
| 141 | stdplus_dl_reqs = [] |
| 142 | foreach dep : stdplus_dl_deps |
| 143 | if dep.type_name() == 'pkgconfig' |
| 144 | stdplus_dl_reqs += dep |
| 145 | endif |
| 146 | endforeach |
| 147 | |
| 148 | import('pkgconfig').generate( |
| 149 | stdplus_dl_lib, |
| 150 | description: 'C++ helper utilities', |
| 151 | version: meson.project_version(), |
| 152 | requires: stdplus_dl_reqs, |
| 153 | ) |
William A. Kennington III | d7acddd | 2022-07-13 16:41:11 -0700 | [diff] [blame] | 154 | endif |
| 155 | |
| 156 | if has_fd |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 157 | stdplus_fd_dep = stdplus_dep |
William A. Kennington III | d7acddd | 2022-07-13 16:41:11 -0700 | [diff] [blame] | 158 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 159 | import('pkgconfig').generate( |
| 160 | stdplus_lib, |
| 161 | name: 'stdplus-fd', |
| 162 | description: 'C++ helper utilities', |
| 163 | version: meson.project_version(), |
| 164 | requires: stdplus_reqs, |
| 165 | ) |
William A. Kennington III | d7acddd | 2022-07-13 16:41:11 -0700 | [diff] [blame] | 166 | endif |
| 167 | |
| 168 | if has_io_uring |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 169 | stdplus_io_uring_deps = [stdplus_dep, stdplus_fd_dep, io_uring_dep] |
William A. Kennington III | ee53ad3 | 2022-07-14 16:14:31 -0700 | [diff] [blame] | 170 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 171 | stdplus_io_uring_pre = declare_dependency( |
| 172 | include_directories: stdplus_io_uring_headers, |
| 173 | dependencies: stdplus_io_uring_deps, |
| 174 | ) |
William A. Kennington III | ee53ad3 | 2022-07-14 16:14:31 -0700 | [diff] [blame] | 175 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 176 | stdplus_io_uring_lib = library( |
| 177 | 'stdplus-io_uring', |
| 178 | 'io_uring.cpp', |
| 179 | dependencies: stdplus_io_uring_pre, |
| 180 | implicit_include_directories: false, |
| 181 | version: meson.project_version(), |
| 182 | build_by_default: not meson.is_subproject(), |
| 183 | install: true, |
| 184 | ) |
William A. Kennington III | ee53ad3 | 2022-07-14 16:14:31 -0700 | [diff] [blame] | 185 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 186 | stdplus_io_uring_dep = declare_dependency( |
| 187 | dependencies: stdplus_io_uring_pre, |
| 188 | link_with: stdplus_io_uring_lib, |
| 189 | ) |
William A. Kennington III | ee53ad3 | 2022-07-14 16:14:31 -0700 | [diff] [blame] | 190 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 191 | stdplus_io_uring_reqs = [] |
| 192 | foreach dep : stdplus_io_uring_deps |
| 193 | if dep.type_name() == 'pkgconfig' |
| 194 | stdplus_io_uring_reqs += dep |
| 195 | endif |
| 196 | endforeach |
William A. Kennington III | d7acddd | 2022-07-13 16:41:11 -0700 | [diff] [blame] | 197 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 198 | import('pkgconfig').generate( |
| 199 | stdplus_io_uring_lib, |
| 200 | description: 'C++ helper utilities', |
| 201 | version: meson.project_version(), |
| 202 | requires: stdplus_io_uring_reqs, |
| 203 | ) |
William A. Kennington III | d7acddd | 2022-07-13 16:41:11 -0700 | [diff] [blame] | 204 | endif |
William A. Kennington III | 953de36 | 2022-07-13 17:32:55 -0700 | [diff] [blame] | 205 | |
| 206 | if has_gtest |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 207 | stdplus_gtest_deps = [fmt_dep, gtest_dep] |
William A. Kennington III | 953de36 | 2022-07-13 17:32:55 -0700 | [diff] [blame] | 208 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 209 | stdplus_gtest_pre = declare_dependency( |
| 210 | include_directories: stdplus_gtest_headers, |
| 211 | dependencies: stdplus_gtest_deps, |
| 212 | ) |
William A. Kennington III | 953de36 | 2022-07-13 17:32:55 -0700 | [diff] [blame] | 213 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 214 | stdplus_gtest_lib = library( |
| 215 | 'stdplus-gtest', |
| 216 | 'gtest/tmp.cpp', |
| 217 | dependencies: stdplus_gtest_pre, |
| 218 | implicit_include_directories: false, |
| 219 | version: meson.project_version(), |
| 220 | build_by_default: not meson.is_subproject(), |
| 221 | install: true, |
| 222 | ) |
William A. Kennington III | 953de36 | 2022-07-13 17:32:55 -0700 | [diff] [blame] | 223 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 224 | stdplus_gtest_dep = declare_dependency( |
| 225 | dependencies: stdplus_gtest_pre, |
| 226 | link_with: stdplus_gtest_lib, |
| 227 | ) |
William A. Kennington III | 953de36 | 2022-07-13 17:32:55 -0700 | [diff] [blame] | 228 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 229 | stdplus_gtest_reqs = [] |
| 230 | foreach dep : stdplus_gtest_deps |
| 231 | if dep.type_name() == 'pkgconfig' |
| 232 | stdplus_gtest_reqs += dep |
| 233 | endif |
| 234 | endforeach |
William A. Kennington III | 953de36 | 2022-07-13 17:32:55 -0700 | [diff] [blame] | 235 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 236 | import('pkgconfig').generate( |
| 237 | stdplus_gtest_lib, |
| 238 | description: 'C++ helper utilities', |
| 239 | version: meson.project_version(), |
| 240 | requires: stdplus_gtest_reqs, |
| 241 | ) |
William A. Kennington III | 2030ea5 | 2022-07-19 17:06:39 -0700 | [diff] [blame] | 242 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 243 | install_data( |
| 244 | 'run_with_tmp', |
| 245 | install_mode: 'rwxr-xr-x', |
| 246 | install_dir: get_option('bindir'), |
| 247 | ) |
William A. Kennington III | 2030ea5 | 2022-07-19 17:06:39 -0700 | [diff] [blame] | 248 | |
Patrick Williams | 6d59258 | 2025-02-01 08:37:30 -0500 | [diff] [blame] | 249 | meson.override_find_program('run_with_tmp', files('run_with_tmp')) |
William A. Kennington III | 953de36 | 2022-07-13 17:32:55 -0700 | [diff] [blame] | 250 | endif |
William A. Kennington III | 2030ea5 | 2022-07-19 17:06:39 -0700 | [diff] [blame] | 251 | |
| 252 | run_with_tmp = find_program('run_with_tmp', native: true) |