build: add support for building with meson

Follow the OpenBMC herd and support a more modern, more comprehensible,
more performant build framework.

To build using meson:
   meson build
   ninja -C build
   ninja -C build install

Added -Dtests to match de-facto OpenBMC meson usage conventions.

Dropped support for --enable-oe-sdk rpath munging.  This was a
workaround for broken oe sdks that don't figure out the correct rpath
when running make check or ninja test.

Ran existing unit tests (which passed) using ninja test.

Change-Id: I198700d866e1b23ba0a22b156335bbb973b98f43
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/gpio-util/meson.build b/gpio-util/meson.build
new file mode 100644
index 0000000..d14cbc3
--- /dev/null
+++ b/gpio-util/meson.build
@@ -0,0 +1,12 @@
+executable(
+    'phosphor-gpio-util',
+    'argument.cpp',
+    'gpio.cpp',
+    'main.cpp',
+    dependencies: [
+        phosphor_logging,
+    ],
+    include_directories: '..',
+    implicit_include_directories: false,
+    install: true,
+)
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..c60e1b4
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,64 @@
+project(
+    'phosphor-gpio-monitor',
+    'cpp',
+    default_options: [
+        'warning_level=3',
+        'werror=true',
+        'cpp_std=c++17'
+    ],
+    license: 'Apache-2.0',
+    version: '1.0',
+)
+
+build_tests = get_option('tests')
+
+cppfs = meson.get_compiler('cpp').find_library('stdc++fs')
+libevdev = dependency('libevdev')
+libsystemd = dependency('libsystemd')
+phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
+phosphor_logging = dependency('phosphor-logging')
+sdbusplus = dependency('sdbusplus')
+
+libevdev_o = static_library(
+    'libevdev_o',
+    'evdev.cpp',
+    dependencies: [
+        libevdev,
+        phosphor_dbus_interfaces,
+        phosphor_logging,
+        sdbusplus,
+    ]
+)
+
+libmonitor_o = static_library(
+    'libmonitor_o',
+     'monitor.cpp',
+    dependencies: [
+        libevdev,
+        libsystemd,
+        phosphor_logging,
+    ],
+    link_with: [
+        libevdev_o,
+    ],
+)
+
+phosphor_gpio_monitor = executable(
+    'phosphor-gpio-monitor',
+    'argument.cpp',
+    'mainapp.cpp',
+    dependencies: [
+        libevdev,
+        libsystemd,
+        phosphor_logging,
+    ],
+    install: true,
+    link_with: [
+        libevdev_o,
+        libmonitor_o,
+    ],
+)
+
+subdir('gpio-util')
+subdir('presence')
+subdir('test')
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..b7869f4
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,3 @@
+option(
+    'tests', type: 'feature', description: 'Build tests.',
+)
diff --git a/presence/meson.build b/presence/meson.build
new file mode 100644
index 0000000..1476e24
--- /dev/null
+++ b/presence/meson.build
@@ -0,0 +1,17 @@
+executable(
+    'phosphor-gpio-presence',
+    'argument.cpp',
+    'main.cpp',
+    'gpio_presence.cpp',
+    dependencies: [
+        cppfs,
+        libevdev,
+        phosphor_logging,
+    ],
+    include_directories: '..',
+    implicit_include_directories: false,
+    install: true,
+    link_with: [
+        libevdev_o,
+    ],
+)
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..c71f83a
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,20 @@
+gmock = dependency('gmock', disabler: true, required: build_tests)
+gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
+
+test(
+    'utest',
+    executable(
+        'utest', 'utest.cpp',
+        dependencies: [
+            gmock,
+            gtest,
+            libevdev,
+        ],
+        implicit_include_directories: false,
+        include_directories: '..',
+        link_with: [
+            libevdev_o,
+            libmonitor_o,
+        ]
+    )
+)