meson: Add alternate build system
For now we will support both the autotools and meson build systems
alongside each other, until support for meson is ready across the
ecosystem.
Tested:
Run through build and unit tests that leverage the new build system
and all of the tests pass and the install puts phosphor-watchdog in
the correct location.
Change-Id: I0454e763acc648ac76efd7728f6da498d9acf5dd
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..75d19e6
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,43 @@
+project('phosphor-watchdog', 'cpp',
+ version: '0.1', meson_version: '>=0.49.0',
+ default_options: [
+ 'warning_level=3',
+ 'werror=true',
+ 'cpp_std=c++17'
+ ])
+
+build_tests = get_option('tests')
+
+phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
+phosphor_logging = dependency('phosphor-logging')
+sdbusplus = dependency('sdbusplus')
+sdeventplus = dependency('sdeventplus')
+
+libwatchdog = static_library(
+ 'watchdog',
+ 'watchdog.cpp',
+ implicit_include_directories: false,
+ dependencies: [
+ phosphor_dbus_interfaces,
+ phosphor_logging,
+ sdbusplus,
+ sdeventplus,
+ ])
+
+executable(
+ 'phosphor-watchdog',
+ 'mainapp.cpp',
+ implicit_include_directories: false,
+ link_with: libwatchdog,
+ dependencies: [
+ phosphor_logging,
+ phosphor_dbus_interfaces,
+ sdbusplus,
+ sdeventplus,
+ ],
+ install: true,
+ install_dir: get_option('sbindir'))
+
+if not build_tests.disabled()
+ subdir('test')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..0fc2767
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1 @@
+option('tests', type: 'feature', description: 'Build tests')
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..4218665
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,13 @@
+gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
+gmock = dependency('gmock', disabler: true, required: build_tests)
+
+tests = [
+ 'watchdog',
+]
+
+foreach t : tests
+ test(t, executable(t.underscorify(), t + '.cpp',
+ implicit_include_directories: false,
+ link_with: libwatchdog,
+ dependencies: [gtest, gmock]))
+endforeach