meson: Add build system
Change-Id: Ia57836a0f7b5287ddb490ba6de01192ce0ef6382
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/example/meson.build b/example/meson.build
new file mode 100644
index 0000000..1cd26b0
--- /dev/null
+++ b/example/meson.build
@@ -0,0 +1,10 @@
+examples = [
+ 'pulse',
+]
+
+foreach example : examples
+ executable(example, example + '.cpp',
+ include_directories: includes,
+ implicit_include_directories: false,
+ link_with: gpioplus)
+endforeach
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..3c82f44
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,21 @@
+project('gpioplus', 'cpp',
+ version: '0.1', meson_version: '>=0.49.0',
+ default_options: [
+ 'warning_level=3',
+ 'werror=true',
+ 'cpp_std=c++17'
+ ])
+
+includes = include_directories('src')
+
+subdir('src')
+
+build_tests = get_option('tests')
+build_examples = get_option('examples')
+
+if build_examples
+ subdir('example')
+endif
+if not build_tests.disabled()
+ subdir('test')
+endif
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..86bc7fc
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,2 @@
+option('tests', type: 'feature', description: 'Build tests')
+option('examples', type: 'boolean', value: true, description: 'Build examples')
diff --git a/src/meson.build b/src/meson.build
new file mode 100644
index 0000000..056a1cd
--- /dev/null
+++ b/src/meson.build
@@ -0,0 +1,40 @@
+gpioplus = library(
+ 'gpioplus',
+ [
+ 'gpioplus/chip.cpp',
+ 'gpioplus/event.cpp',
+ 'gpioplus/handle.cpp',
+ 'gpioplus/internal/fd.cpp',
+ 'gpioplus/internal/sys.cpp',
+ ],
+ include_directories: includes,
+ implicit_include_directories: false,
+ version: meson.project_version(),
+ install: true)
+
+import('pkgconfig').generate(
+ name: 'gpioplus',
+ description: 'C++ systemd event wrapper',
+ version: meson.project_version(),
+)
+
+install_headers(
+ 'gpioplus/chip.hpp',
+ 'gpioplus/event.hpp',
+ 'gpioplus/handle.hpp',
+ subdir: 'gpioplus')
+
+install_headers(
+ 'gpioplus/internal/fd.hpp',
+ 'gpioplus/internal/sys.hpp',
+ subdir: 'gpioplus/internal')
+
+install_headers(
+ 'gpioplus/test/event.hpp',
+ 'gpioplus/test/handle.hpp',
+ 'gpioplus/test/sys.hpp',
+ subdir: 'gpioplus/test')
+
+install_headers(
+ 'gpioplus/utility/aspeed.hpp',
+ subdir: 'gpioplus/utility')
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..84abb79
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,19 @@
+gtest = dependency('gtest', main: true, disabler: true, required: build_tests)
+gmock = dependency('gmock', disabler: true, required: build_tests)
+
+tests = [
+ 'chip',
+ 'event',
+ 'handle',
+ 'internal/fd',
+ 'mocks',
+ 'utility/aspeed',
+]
+
+foreach t : tests
+ test(t, executable(t.underscorify(), t + '.cpp',
+ include_directories: includes,
+ implicit_include_directories: false,
+ link_with: gpioplus,
+ dependencies: [gtest, gmock]))
+endforeach