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