raw: Add class for extracting bytes into structures

Change-Id: I30364d9fc5a5f02ee27e6b8fd17f40226b44dcc4
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/meson.build b/src/meson.build
index aadb68d..11080b0 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -1,5 +1,54 @@
 stdplus_headers = include_directories('.')
 
+fmt_dep = dependency('fmt', required: false)
+fmt_ext = fmt_dep
+if not fmt_dep.found()
+  fmt_proj = import('cmake').subproject(
+    'fmt',
+    cmake_options: [
+      '-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
+      '-DMASTER_PROJECT=OFF'
+    ],
+    required: false)
+  assert(fmt_proj.found(), 'fmtlib is required')
+  fmt_dep = fmt_proj.dependency('fmt')
+endif
+
+# span-lite might not have a pkg-config. It is header only so just make
+# sure we can access the needed symbols from the header.
+span_dep = dependency('', required: false)
+span_ext = span_dep
+has_span = meson.get_compiler('cpp').has_header_symbol(
+  'span',
+  'std::dynamic_extent',
+  dependencies: span_dep,
+  required: false)
+if not has_span
+  span_dep = dependency('span-lite', required: false)
+  span_ext = span_dep
+  has_span = meson.get_compiler('cpp').has_header_symbol(
+    'nonstd/span.hpp',
+    'nonstd::dynamic_extent',
+    dependencies: span_dep,
+    required: false)
+  if not has_span
+    span_lite_proj = import('cmake').subproject(
+      'span-lite',
+      cmake_options: [
+      ],
+      required: false)
+    if span_lite_proj.found()
+      span_dep = span_lite_proj.dependency('span-lite')
+      has_span = true
+    endif
+  endif
+endif
+
+stdplus_deps = [
+  fmt_dep,
+  span_dep,
+]
+
 stdplus_lib = library(
   'stdplus',
   [
@@ -7,10 +56,12 @@
   ],
   include_directories: stdplus_headers,
   implicit_include_directories: false,
+  dependencies: stdplus_deps,
   version: meson.project_version(),
   install: true)
 
 stdplus = declare_dependency(
+  dependencies: stdplus_deps,
   include_directories: stdplus_headers,
   link_with: stdplus_lib)
 
@@ -18,9 +69,11 @@
   name: 'stdplus',
   description: 'C++ helper utilities',
   version: meson.project_version(),
-  libraries: stdplus)
+  libraries: stdplus,
+  requires: [fmt_ext, span_ext])
 
 install_headers(
+  'stdplus/raw.hpp',
   'stdplus/signal.hpp',
   subdir: 'stdplus')