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() |
| 5 | fmt_proj = import('cmake').subproject( |
| 6 | 'fmt', |
| 7 | cmake_options: [ |
| 8 | '-DCMAKE_POSITION_INDEPENDENT_CODE=ON', |
| 9 | '-DMASTER_PROJECT=OFF' |
| 10 | ], |
| 11 | required: false) |
| 12 | assert(fmt_proj.found(), 'fmtlib is required') |
| 13 | fmt_dep = fmt_proj.dependency('fmt') |
| 14 | endif |
| 15 | |
| 16 | # span-lite 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 | span_dep = dependency('', required: false) |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 19 | has_span = meson.get_compiler('cpp').has_header_symbol( |
| 20 | 'span', |
| 21 | 'std::dynamic_extent', |
| 22 | dependencies: span_dep, |
| 23 | required: false) |
| 24 | if not has_span |
| 25 | span_dep = dependency('span-lite', required: false) |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 26 | has_span = meson.get_compiler('cpp').has_header_symbol( |
| 27 | 'nonstd/span.hpp', |
| 28 | 'nonstd::dynamic_extent', |
| 29 | dependencies: span_dep, |
| 30 | required: false) |
| 31 | if not has_span |
| 32 | span_lite_proj = import('cmake').subproject( |
| 33 | 'span-lite', |
| 34 | cmake_options: [ |
| 35 | ], |
| 36 | required: false) |
| 37 | if span_lite_proj.found() |
| 38 | span_dep = span_lite_proj.dependency('span-lite') |
| 39 | has_span = true |
| 40 | endif |
| 41 | endif |
| 42 | endif |
| 43 | |
| 44 | stdplus_deps = [ |
| 45 | fmt_dep, |
| 46 | span_dep, |
| 47 | ] |
| 48 | |
William A. Kennington III | 97e3947 | 2019-04-03 13:22:32 -0700 | [diff] [blame] | 49 | stdplus_lib = library( |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 50 | 'stdplus', |
| 51 | [ |
| 52 | 'stdplus/signal.cpp', |
| 53 | ], |
William A. Kennington III | 97e3947 | 2019-04-03 13:22:32 -0700 | [diff] [blame] | 54 | include_directories: stdplus_headers, |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 55 | implicit_include_directories: false, |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 56 | dependencies: stdplus_deps, |
William A. Kennington III | 1937ef6 | 2019-03-28 03:24:57 -0700 | [diff] [blame] | 57 | version: meson.project_version(), |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 58 | install: true) |
| 59 | |
William A. Kennington III | 97e3947 | 2019-04-03 13:22:32 -0700 | [diff] [blame] | 60 | stdplus = declare_dependency( |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 61 | dependencies: stdplus_deps, |
William A. Kennington III | 97e3947 | 2019-04-03 13:22:32 -0700 | [diff] [blame] | 62 | include_directories: stdplus_headers, |
| 63 | link_with: stdplus_lib) |
| 64 | |
William A. Kennington III | b01c557 | 2020-06-03 19:40:49 -0700 | [diff] [blame^] | 65 | stdplus_reqs = [] |
| 66 | foreach dep : stdplus_deps |
| 67 | if dep.type_name() == 'pkgconfig' |
| 68 | stdplus_reqs += dep |
| 69 | endif |
| 70 | endforeach |
| 71 | |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 72 | import('pkgconfig').generate( |
| 73 | name: 'stdplus', |
| 74 | description: 'C++ helper utilities', |
| 75 | version: meson.project_version(), |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 76 | libraries: stdplus, |
William A. Kennington III | b01c557 | 2020-06-03 19:40:49 -0700 | [diff] [blame^] | 77 | requires: stdplus_reqs) |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 78 | |
| 79 | install_headers( |
William A. Kennington III | e099038 | 2019-10-18 02:10:25 -0700 | [diff] [blame] | 80 | 'stdplus/raw.hpp', |
William A. Kennington III | 15982f6 | 2019-01-31 14:43:41 -0800 | [diff] [blame] | 81 | 'stdplus/signal.hpp', |
| 82 | subdir: 'stdplus') |
William A. Kennington III | 7a5e232 | 2018-11-02 17:28:35 -0700 | [diff] [blame] | 83 | |
| 84 | install_headers( |
William A. Kennington III | e847ef8 | 2018-11-02 17:29:15 -0700 | [diff] [blame] | 85 | 'stdplus/handle/copyable.hpp', |
William A. Kennington III | 7a5e232 | 2018-11-02 17:28:35 -0700 | [diff] [blame] | 86 | 'stdplus/handle/managed.hpp', |
| 87 | subdir: 'stdplus/handle') |
William A. Kennington III | bff0b0f | 2018-11-16 19:56:10 -0800 | [diff] [blame] | 88 | |
| 89 | install_headers( |
| 90 | 'stdplus/util/cexec.hpp', |
William A. Kennington III | 4ef36e7 | 2019-06-27 12:48:59 -0700 | [diff] [blame] | 91 | 'stdplus/util/string.hpp', |
William A. Kennington III | bff0b0f | 2018-11-16 19:56:10 -0800 | [diff] [blame] | 92 | subdir: 'stdplus/util') |