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