blob: ddaf341cff5c992afc63ee77d7915c2a0ef4a59b [file] [log] [blame]
William A. Kennington III97e39472019-04-03 13:22:32 -07001stdplus_headers = include_directories('.')
2
William A. Kennington IIIe0990382019-10-18 02:10:25 -07003fmt_dep = dependency('fmt', required: false)
William A. Kennington IIIe0990382019-10-18 02:10:25 -07004if 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')
14endif
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.
18span_dep = dependency('', required: false)
William A. Kennington IIIe0990382019-10-18 02:10:25 -070019has_span = meson.get_compiler('cpp').has_header_symbol(
20 'span',
21 'std::dynamic_extent',
22 dependencies: span_dep,
23 required: false)
24if not has_span
25 span_dep = dependency('span-lite', required: false)
William A. Kennington IIIe0990382019-10-18 02:10:25 -070026 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
42endif
43
44stdplus_deps = [
45 fmt_dep,
46 span_dep,
47]
48
William A. Kennington III97e39472019-04-03 13:22:32 -070049stdplus_lib = library(
William A. Kennington III15982f62019-01-31 14:43:41 -080050 'stdplus',
51 [
52 'stdplus/signal.cpp',
53 ],
William A. Kennington III97e39472019-04-03 13:22:32 -070054 include_directories: stdplus_headers,
William A. Kennington III15982f62019-01-31 14:43:41 -080055 implicit_include_directories: false,
William A. Kennington IIIe0990382019-10-18 02:10:25 -070056 dependencies: stdplus_deps,
William A. Kennington III1937ef62019-03-28 03:24:57 -070057 version: meson.project_version(),
William A. Kennington III15982f62019-01-31 14:43:41 -080058 install: true)
59
William A. Kennington III97e39472019-04-03 13:22:32 -070060stdplus = declare_dependency(
William A. Kennington IIIe0990382019-10-18 02:10:25 -070061 dependencies: stdplus_deps,
William A. Kennington III97e39472019-04-03 13:22:32 -070062 include_directories: stdplus_headers,
63 link_with: stdplus_lib)
64
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070065stdplus_reqs = []
66foreach dep : stdplus_deps
67 if dep.type_name() == 'pkgconfig'
William A. Kennington III285fbcb2021-01-24 18:16:20 -080068 stdplus_reqs += dep
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070069 endif
70endforeach
71
William A. Kennington III15982f62019-01-31 14:43:41 -080072import('pkgconfig').generate(
William A. Kennington III285fbcb2021-01-24 18:16:20 -080073 stdplus_lib,
William A. Kennington III15982f62019-01-31 14:43:41 -080074 description: 'C++ helper utilities',
75 version: meson.project_version(),
William A. Kennington IIIb01c5572020-06-03 19:40:49 -070076 requires: stdplus_reqs)
William A. Kennington III15982f62019-01-31 14:43:41 -080077
78install_headers(
William A. Kennington IIIe0990382019-10-18 02:10:25 -070079 'stdplus/raw.hpp',
William A. Kennington III15982f62019-01-31 14:43:41 -080080 'stdplus/signal.hpp',
William A. Kennington IIIda284aa2020-06-03 19:41:10 -070081 'stdplus/types.hpp',
William A. Kennington III15982f62019-01-31 14:43:41 -080082 subdir: 'stdplus')
William A. Kennington III7a5e2322018-11-02 17:28:35 -070083
84install_headers(
William A. Kennington IIIe847ef82018-11-02 17:29:15 -070085 'stdplus/handle/copyable.hpp',
William A. Kennington III7a5e2322018-11-02 17:28:35 -070086 'stdplus/handle/managed.hpp',
87 subdir: 'stdplus/handle')
William A. Kennington IIIbff0b0f2018-11-16 19:56:10 -080088
89install_headers(
90 'stdplus/util/cexec.hpp',
William A. Kennington III4ef36e72019-06-27 12:48:59 -070091 'stdplus/util/string.hpp',
William A. Kennington IIIbff0b0f2018-11-16 19:56:10 -080092 subdir: 'stdplus/util')