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 | |
| 18 | # span-lite might not have a pkg-config. It is header only so just make |
| 19 | # sure we can access the needed symbols from the header. |
William A. Kennington III | f65edcb | 2021-01-30 15:45:35 -0800 | [diff] [blame] | 20 | span_dep = dependency('span-lite', required: false) |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 21 | has_span = meson.get_compiler('cpp').has_header_symbol( |
William A. Kennington III | f65edcb | 2021-01-30 15:45:35 -0800 | [diff] [blame] | 22 | 'nonstd/span.hpp', |
William A. Kennington III | af0e0e8 | 2021-05-15 00:57:23 -0700 | [diff] [blame] | 23 | 'nonstd::span<int>', |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 24 | dependencies: span_dep, |
| 25 | required: false) |
| 26 | if not has_span |
William A. Kennington III | f65edcb | 2021-01-30 15:45:35 -0800 | [diff] [blame] | 27 | span_lite_proj = import('cmake').subproject( |
| 28 | 'span-lite', |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 29 | required: false) |
William A. Kennington III | f65edcb | 2021-01-30 15:45:35 -0800 | [diff] [blame] | 30 | if span_lite_proj.found() |
| 31 | span_dep = span_lite_proj.dependency('span-lite') |
| 32 | has_span = true |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 33 | endif |
| 34 | endif |
| 35 | |
| 36 | stdplus_deps = [ |
| 37 | fmt_dep, |
| 38 | span_dep, |
| 39 | ] |
| 40 | |
William A. Kennington III | 4575424 | 2021-04-28 12:48:31 -0700 | [diff] [blame] | 41 | stdplus_srcs = [ |
| 42 | 'stdplus/exception.cpp', |
| 43 | 'stdplus/signal.cpp', |
| 44 | ] |
| 45 | |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 46 | has_fd = false |
| 47 | if not get_option('fd').disabled() and has_span |
| 48 | has_fd = true |
| 49 | |
William A. Kennington III | 4575424 | 2021-04-28 12:48:31 -0700 | [diff] [blame] | 50 | stdplus_srcs += [ |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 51 | 'stdplus/fd/create.cpp', |
| 52 | 'stdplus/fd/dupable.cpp', |
| 53 | 'stdplus/fd/impl.cpp', |
| 54 | 'stdplus/fd/managed.cpp', |
| 55 | 'stdplus/fd/ops.cpp', |
| 56 | ] |
| 57 | |
| 58 | install_headers( |
| 59 | 'stdplus/fd/create.hpp', |
| 60 | 'stdplus/fd/dupable.hpp', |
| 61 | 'stdplus/fd/gmock.hpp', |
| 62 | 'stdplus/fd/impl.hpp', |
| 63 | 'stdplus/fd/intf.hpp', |
| 64 | 'stdplus/fd/managed.hpp', |
| 65 | 'stdplus/fd/ops.hpp', |
| 66 | subdir: 'stdplus/fd') |
| 67 | elif get_option('fd').enabled() |
| 68 | error('File descriptor support required') |
| 69 | endif |
| 70 | |
William A. Kennington III | 5c20da2 | 2021-06-18 16:44:55 -0700 | [diff] [blame] | 71 | io_uring_dep = dependency('liburing', required: get_option('io_uring')) |
| 72 | has_io_uring = false |
| 73 | if not get_option('io_uring').disabled() and has_fd and io_uring_dep.found() |
| 74 | has_io_uring = true |
| 75 | |
| 76 | stdplus_deps += [ |
| 77 | io_uring_dep, |
| 78 | ] |
| 79 | |
| 80 | stdplus_srcs += [ |
| 81 | 'stdplus/io_uring.cpp', |
| 82 | ] |
| 83 | |
| 84 | install_headers( |
| 85 | 'stdplus/io_uring.hpp', |
| 86 | subdir: 'stdplus') |
| 87 | elif get_option('io_uring').enabled() |
| 88 | error('File descriptor support required') |
| 89 | endif |
| 90 | |
William A. Kennington III | 97e3947 | 2019-04-03 13:22:32 -0700 | [diff] [blame] | 91 | stdplus_lib = library( |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 92 | 'stdplus', |
William A. Kennington III | 4575424 | 2021-04-28 12:48:31 -0700 | [diff] [blame] | 93 | stdplus_srcs, |
William A. Kennington III | 97e3947 | 2019-04-03 13:22:32 -0700 | [diff] [blame] | 94 | include_directories: stdplus_headers, |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 95 | implicit_include_directories: false, |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 96 | dependencies: stdplus_deps, |
William A. Kennington III | 1937ef6 | 2019-03-28 03:24:57 -0700 | [diff] [blame] | 97 | version: meson.project_version(), |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 98 | install: true) |
| 99 | |
William A. Kennington III | 3acf92b | 2021-04-16 13:33:50 -0700 | [diff] [blame] | 100 | stdplus_dep = declare_dependency( |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 101 | dependencies: stdplus_deps, |
William A. Kennington III | 97e3947 | 2019-04-03 13:22:32 -0700 | [diff] [blame] | 102 | include_directories: stdplus_headers, |
| 103 | link_with: stdplus_lib) |
| 104 | |
William A. Kennington III | b01c557 | 2020-06-03 19:40:49 -0700 | [diff] [blame] | 105 | stdplus_reqs = [] |
| 106 | foreach dep : stdplus_deps |
| 107 | if dep.type_name() == 'pkgconfig' |
William A. Kennington III | 285fbcb | 2021-01-24 18:16:20 -0800 | [diff] [blame] | 108 | stdplus_reqs += dep |
William A. Kennington III | b01c557 | 2020-06-03 19:40:49 -0700 | [diff] [blame] | 109 | endif |
| 110 | endforeach |
| 111 | |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 112 | import('pkgconfig').generate( |
William A. Kennington III | 285fbcb | 2021-01-24 18:16:20 -0800 | [diff] [blame] | 113 | stdplus_lib, |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 114 | description: 'C++ helper utilities', |
| 115 | version: meson.project_version(), |
William A. Kennington III | b01c557 | 2020-06-03 19:40:49 -0700 | [diff] [blame] | 116 | requires: stdplus_reqs) |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 117 | |
| 118 | install_headers( |
William A. Kennington III | 458aeae | 2021-06-14 15:07:16 -0700 | [diff] [blame] | 119 | 'stdplus/cancel.hpp', |
William A. Kennington III | 2f21073 | 2020-08-02 16:12:36 -0700 | [diff] [blame] | 120 | 'stdplus/exception.hpp', |
William A. Kennington III | eac9d47 | 2020-08-03 13:57:14 -0700 | [diff] [blame] | 121 | 'stdplus/flags.hpp', |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 122 | 'stdplus/raw.hpp', |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 123 | 'stdplus/signal.hpp', |
William A. Kennington III | da284aa | 2020-06-03 19:41:10 -0700 | [diff] [blame] | 124 | 'stdplus/types.hpp', |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 125 | subdir: 'stdplus') |
William A. Kennington III | 7a5e232 | 2018-11-02 17:28:35 -0700 | [diff] [blame] | 126 | |
| 127 | install_headers( |
William A. Kennington III | e847ef8 | 2018-11-02 17:29:15 -0700 | [diff] [blame] | 128 | 'stdplus/handle/copyable.hpp', |
William A. Kennington III | 7a5e232 | 2018-11-02 17:28:35 -0700 | [diff] [blame] | 129 | 'stdplus/handle/managed.hpp', |
| 130 | subdir: 'stdplus/handle') |
William A. Kennington III | bff0b0f | 2018-11-16 19:56:10 -0800 | [diff] [blame] | 131 | |
| 132 | install_headers( |
| 133 | 'stdplus/util/cexec.hpp', |
William A. Kennington III | 4ef36e7 | 2019-06-27 12:48:59 -0700 | [diff] [blame] | 134 | 'stdplus/util/string.hpp', |
William A. Kennington III | bff0b0f | 2018-11-16 19:56:10 -0800 | [diff] [blame] | 135 | subdir: 'stdplus/util') |