William A. Kennington III | 97e3947 | 2019-04-03 13:22:32 -0700 | [diff] [blame] | 1 | stdplus_headers = include_directories('.') |
| 2 | |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 3 | fmt_dep = dependency('fmt', required: false) |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 4 | if not fmt_dep.found() |
William A. Kennington III | b5d1c58 | 2021-04-16 13:41:39 -0700 | [diff] [blame] | 5 | 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 III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 10 | fmt_proj = import('cmake').subproject( |
| 11 | 'fmt', |
William A. Kennington III | b5d1c58 | 2021-04-16 13:41:39 -0700 | [diff] [blame] | 12 | options: fmt_opts, |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 13 | required: false) |
| 14 | assert(fmt_proj.found(), 'fmtlib is required') |
| 15 | fmt_dep = fmt_proj.dependency('fmt') |
| 16 | endif |
| 17 | |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 18 | stdplus_deps = [ |
| 19 | fmt_dep, |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 20 | ] |
| 21 | |
William A. Kennington III | 4575424 | 2021-04-28 12:48:31 -0700 | [diff] [blame] | 22 | stdplus_srcs = [ |
| 23 | 'stdplus/exception.cpp', |
| 24 | 'stdplus/signal.cpp', |
| 25 | ] |
| 26 | |
William A. Kennington III | 5a52802 | 2021-04-28 12:52:43 -0700 | [diff] [blame] | 27 | has_dl = false |
| 28 | if not get_option('dl').disabled() |
| 29 | dl_dep = meson.get_compiler('cpp').find_library('dl', required: false) |
William A. Kennington III | 8b70ecc | 2021-10-28 21:13:14 -0700 | [diff] [blame] | 30 | has_dl = meson.get_compiler('cpp').links(''' |
William A. Kennington III | 5a52802 | 2021-04-28 12:52:43 -0700 | [diff] [blame] | 31 | #include <dlfcn.h> |
| 32 | int main() { dlopen("", 0); } |
William A. Kennington III | 8b70ecc | 2021-10-28 21:13:14 -0700 | [diff] [blame] | 33 | ''', dependencies: dl_dep) |
William A. Kennington III | 5a52802 | 2021-04-28 12:52:43 -0700 | [diff] [blame] | 34 | endif |
| 35 | if has_dl |
| 36 | stdplus_deps += [ |
| 37 | dl_dep, |
| 38 | ] |
| 39 | |
| 40 | stdplus_srcs += [ |
| 41 | 'stdplus/dl.cpp', |
| 42 | ] |
| 43 | |
| 44 | install_headers( |
| 45 | 'stdplus/dl.hpp', |
| 46 | subdir: 'stdplus') |
| 47 | elif get_option('dl').enabled() |
| 48 | error('libdl support required') |
| 49 | endif |
| 50 | |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 51 | has_fd = false |
Patrick Williams | 68975b9 | 2022-04-27 16:00:26 -0500 | [diff] [blame] | 52 | if not get_option('fd').disabled() |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 53 | has_fd = true |
| 54 | |
William A. Kennington III | 4575424 | 2021-04-28 12:48:31 -0700 | [diff] [blame] | 55 | stdplus_srcs += [ |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 56 | 'stdplus/fd/create.cpp', |
| 57 | 'stdplus/fd/dupable.cpp', |
| 58 | 'stdplus/fd/impl.cpp', |
| 59 | 'stdplus/fd/managed.cpp', |
William A. Kennington III | 891e6a3 | 2022-05-17 16:35:03 -0700 | [diff] [blame^] | 60 | 'stdplus/fd/mmap.cpp', |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 61 | 'stdplus/fd/ops.cpp', |
| 62 | ] |
| 63 | |
| 64 | install_headers( |
| 65 | 'stdplus/fd/create.hpp', |
| 66 | 'stdplus/fd/dupable.hpp', |
| 67 | 'stdplus/fd/gmock.hpp', |
| 68 | 'stdplus/fd/impl.hpp', |
| 69 | 'stdplus/fd/intf.hpp', |
| 70 | 'stdplus/fd/managed.hpp', |
William A. Kennington III | 891e6a3 | 2022-05-17 16:35:03 -0700 | [diff] [blame^] | 71 | 'stdplus/fd/mmap.hpp', |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 72 | 'stdplus/fd/ops.hpp', |
| 73 | subdir: 'stdplus/fd') |
| 74 | elif get_option('fd').enabled() |
| 75 | error('File descriptor support required') |
| 76 | endif |
| 77 | |
William A. Kennington III | 5c20da2 | 2021-06-18 16:44:55 -0700 | [diff] [blame] | 78 | io_uring_dep = dependency('liburing', required: get_option('io_uring')) |
| 79 | has_io_uring = false |
| 80 | if not get_option('io_uring').disabled() and has_fd and io_uring_dep.found() |
| 81 | has_io_uring = true |
| 82 | |
| 83 | stdplus_deps += [ |
| 84 | io_uring_dep, |
| 85 | ] |
| 86 | |
| 87 | stdplus_srcs += [ |
| 88 | 'stdplus/io_uring.cpp', |
| 89 | ] |
| 90 | |
| 91 | install_headers( |
| 92 | 'stdplus/io_uring.hpp', |
| 93 | subdir: 'stdplus') |
| 94 | elif get_option('io_uring').enabled() |
| 95 | error('File descriptor support required') |
| 96 | endif |
| 97 | |
William A. Kennington III | 97e3947 | 2019-04-03 13:22:32 -0700 | [diff] [blame] | 98 | stdplus_lib = library( |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 99 | 'stdplus', |
William A. Kennington III | 4575424 | 2021-04-28 12:48:31 -0700 | [diff] [blame] | 100 | stdplus_srcs, |
William A. Kennington III | 97e3947 | 2019-04-03 13:22:32 -0700 | [diff] [blame] | 101 | include_directories: stdplus_headers, |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 102 | implicit_include_directories: false, |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 103 | dependencies: stdplus_deps, |
William A. Kennington III | 1937ef6 | 2019-03-28 03:24:57 -0700 | [diff] [blame] | 104 | version: meson.project_version(), |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 105 | install: true) |
| 106 | |
William A. Kennington III | 3acf92b | 2021-04-16 13:33:50 -0700 | [diff] [blame] | 107 | stdplus_dep = declare_dependency( |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 108 | dependencies: stdplus_deps, |
William A. Kennington III | 97e3947 | 2019-04-03 13:22:32 -0700 | [diff] [blame] | 109 | include_directories: stdplus_headers, |
| 110 | link_with: stdplus_lib) |
| 111 | |
William A. Kennington III | b01c557 | 2020-06-03 19:40:49 -0700 | [diff] [blame] | 112 | stdplus_reqs = [] |
| 113 | foreach dep : stdplus_deps |
| 114 | if dep.type_name() == 'pkgconfig' |
William A. Kennington III | 285fbcb | 2021-01-24 18:16:20 -0800 | [diff] [blame] | 115 | stdplus_reqs += dep |
William A. Kennington III | b01c557 | 2020-06-03 19:40:49 -0700 | [diff] [blame] | 116 | endif |
| 117 | endforeach |
| 118 | |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 119 | import('pkgconfig').generate( |
William A. Kennington III | 285fbcb | 2021-01-24 18:16:20 -0800 | [diff] [blame] | 120 | stdplus_lib, |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 121 | description: 'C++ helper utilities', |
| 122 | version: meson.project_version(), |
William A. Kennington III | b01c557 | 2020-06-03 19:40:49 -0700 | [diff] [blame] | 123 | requires: stdplus_reqs) |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 124 | |
| 125 | install_headers( |
William A. Kennington III | 458aeae | 2021-06-14 15:07:16 -0700 | [diff] [blame] | 126 | 'stdplus/cancel.hpp', |
William A. Kennington III | 2f21073 | 2020-08-02 16:12:36 -0700 | [diff] [blame] | 127 | 'stdplus/exception.hpp', |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 128 | 'stdplus/flags.hpp', |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 129 | 'stdplus/raw.hpp', |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 130 | 'stdplus/signal.hpp', |
| 131 | subdir: 'stdplus') |
William A. Kennington III | 7a5e232 | 2018-11-02 17:28:35 -0700 | [diff] [blame] | 132 | |
| 133 | install_headers( |
William A. Kennington III | e847ef8 | 2018-11-02 17:29:15 -0700 | [diff] [blame] | 134 | 'stdplus/handle/copyable.hpp', |
William A. Kennington III | 7a5e232 | 2018-11-02 17:28:35 -0700 | [diff] [blame] | 135 | 'stdplus/handle/managed.hpp', |
| 136 | subdir: 'stdplus/handle') |
William A. Kennington III | bff0b0f | 2018-11-16 19:56:10 -0800 | [diff] [blame] | 137 | |
| 138 | install_headers( |
| 139 | 'stdplus/util/cexec.hpp', |
William A. Kennington III | 4ef36e7 | 2019-06-27 12:48:59 -0700 | [diff] [blame] | 140 | 'stdplus/util/string.hpp', |
William A. Kennington III | bff0b0f | 2018-11-16 19:56:10 -0800 | [diff] [blame] | 141 | subdir: 'stdplus/util') |