build: Propagate function2
This is a useful header only dependency that is leveraged by many
projects. We will use it in future commits and we want dependees to be
able to use it.
Change-Id: Iea2856190678a2cfef742757ad96f9ea872377cc
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/src/meson.build b/src/meson.build
index bdb8f67..a59cffd 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -13,8 +13,32 @@
fmt_dep = fmt_proj.dependency('fmt')
endif
+# Function2 might not have a pkg-config. It is header only so just make
+# sure we can access the needed symbols from the header.
+function2_dep = dependency('function2', required: false)
+has_function2 = meson.get_compiler('cpp').has_header_symbol(
+ 'function2/function2.hpp',
+ 'fu2::unique_function',
+ dependencies: function2_dep,
+ required: false
+)
+if not has_function2
+ function2_opts = import('cmake').subproject_options()
+ function2_opts.add_cmake_defines({'BUILD_TESTING': 'OFF'})
+ function2_proj = import('cmake').subproject(
+ 'function2',
+ options: function2_opts,
+ required: false
+ )
+ assert(function2_proj.found(), 'function2 is required')
+ if function2_proj.found()
+ function2_dep = function2_proj.dependency('function2')
+ endif
+endif
+
stdplus_deps = [
fmt_dep,
+ function2_dep,
]
stdplus_srcs = [