meson: Support building boost as subproject
Add support for the local meson build on the system without boost.
Tested:
"meson setup build && cd build && meson compile" finishes successfully.
Change-Id: I22eb23c216f9333589ab61ae4d1cb707be5c9a0a
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
diff --git a/meson.build b/meson.build
index 741347b..1c4e4bf 100644
--- a/meson.build
+++ b/meson.build
@@ -7,6 +7,7 @@
'warning_level=3',
'werror=true',
'cpp_std=c++23',
+ 'b_lto=true',
],
)
@@ -28,7 +29,23 @@
'boost',
modules: ['coroutine'],
include_type: 'system',
+ required: false,
)
+
+if not boost_dep.found()
+ cmake = import('cmake')
+ opt = cmake.subproject_options()
+ opt.add_cmake_defines({
+ 'BOOST_INCLUDE_LIBRARIES': 'asio;callable_traits;context;coroutine',
+ })
+ boost_cmake = cmake.subproject('boost', required: true, options: opt)
+ boost_asio = boost_cmake.dependency('boost_asio').as_system()
+ boost_callable_traits = boost_cmake.dependency('boost_callable_traits').as_system()
+ boost_context = boost_cmake.dependency('boost_context').as_system()
+ boost_coroutine = boost_cmake.dependency('boost_coroutine').as_system()
+ boost_dep = [boost_asio, boost_callable_traits, boost_context, boost_coroutine]
+endif
+
i2c_dep = cpp.find_library('i2c')
nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
phosphor_logging_dep = dependency('phosphor-logging')
diff --git a/subprojects/boost.wrap b/subprojects/boost.wrap
new file mode 100644
index 0000000..5912c6f
--- /dev/null
+++ b/subprojects/boost.wrap
@@ -0,0 +1,9 @@
+[wrap-file]
+directory = boost-1.84.0
+
+source_url = https://github.com/boostorg/boost/releases/download/boost-1.84.0/boost-1.84.0.tar.gz
+source_hash = 4d27e9efed0f6f152dc28db6430b9d3dfb40c0345da7342eaa5a987dde57bd95
+source_filename = 1_84_0.tar.gz
+
+[provide]
+boost = boost_dep