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