meson: feature match autotools support
Add support to build the example and test directories, which
will get us feature match with the current autotools-based build.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ib0789b6a715be366601eb639fd70ca3da9536a66
diff --git a/example/meson.build b/example/meson.build
new file mode 100644
index 0000000..bd0e7c6
--- /dev/null
+++ b/example/meson.build
@@ -0,0 +1,43 @@
+executable(
+ 'list-users',
+ 'list-users.cpp',
+ include_directories: root_inc,
+ link_with: libsdbusplus,
+ dependencies: libsystemd_pkg,
+)
+
+if boost_dep.found()
+ executable(
+ 'asio-example',
+ 'asio-example.cpp',
+ cpp_args: [
+ '-DBOOST_ALL_NO_LIB',
+ '-DBOOST_SYSTEM_NO_DEPRECATED',
+ '-DBOOST_ERROR_CODE_HEADER_ONLY',
+ '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
+ ],
+ include_directories: root_inc,
+ link_with: libsdbusplus,
+ dependencies: [ boost_dep, pthread_dep, libsystemd_pkg ],
+ )
+endif
+
+calc_buildroot = meson.current_build_dir()
+calc_files = files(
+ run_command(
+ sdbusgen_prog,
+ '--tool', sdbusplusplus_prog,
+ '--output', calc_buildroot,
+ 'net',
+ check: true
+ ).stdout().strip().split('\n')
+)
+
+executable(
+ 'calculator-server',
+ 'calculator-server.cpp',
+ calc_files,
+ include_directories: root_inc,
+ link_with: libsdbusplus,
+ dependencies: libsystemd_pkg,
+)
diff --git a/meson.build b/meson.build
index 705efe5..a965d14 100644
--- a/meson.build
+++ b/meson.build
@@ -1,4 +1,4 @@
-project('sdbusplus', 'cpp',
+project('sdbusplus', 'cpp', 'c',
default_options: [
'buildtype=debugoptimized',
'cpp_std=c++17',
@@ -8,6 +8,7 @@
)
libsystemd_pkg = dependency('libsystemd')
+root_inc = include_directories('.')
libsdbusplus_src = files(
'sdbusplus/exception.cpp',
@@ -23,6 +24,18 @@
install: true,
)
+subdir('tools')
+
+boost_dep = dependency(
+ 'boost',
+ required: false,
+ modules: [ 'coroutine' ],
+)
+pthread_dep = dependency('threads')
+
+subdir('example')
+subdir('test')
+
install_subdir(
'sdbusplus',
install_dir: get_option('includedir'),
diff --git a/test/meson.build b/test/meson.build
new file mode 100644
index 0000000..7debf0e
--- /dev/null
+++ b/test/meson.build
@@ -0,0 +1,76 @@
+gtest_dep = dependency('gtest')
+gtest_main_dep = dependency('gtest_main')
+gmock_dep = dependency('gmock')
+gmock_main_dep = dependency('gmock_main')
+
+tests = [
+ 'bus/list_names',
+ 'bus/match',
+ 'exception/sdbus_error',
+ 'message/append',
+ 'message/read',
+ 'message/native_types',
+ 'message/types',
+ 'timer',
+ 'utility/tuple_to_array',
+ 'utility/type_traits',
+]
+
+foreach t : tests
+ test(
+ 'test_' + t.underscorify(),
+ executable(
+ 'test-' + t.underscorify(),
+ t + '.cpp',
+ include_directories: root_inc,
+ link_with: libsdbusplus,
+ dependencies: [
+ gtest_dep,
+ gmock_dep,
+ gmock_main_dep,
+ libsystemd_pkg,
+ ],
+ )
+ )
+endforeach
+
+test(
+ 'test-vtable',
+ executable(
+ 'test-vtable',
+ 'vtable/vtable.cpp',
+ 'vtable/vtable_c.c',
+ include_directories: root_inc,
+ link_with: libsdbusplus,
+ dependencies: [ gtest_dep, gtest_main_dep, libsystemd_pkg ],
+ ),
+)
+
+server_buildroot = meson.current_build_dir()
+server_files = files(
+ run_command(
+ sdbusgen_prog,
+ '--tool', sdbusplusplus_prog,
+ '--output', server_buildroot,
+ 'server',
+ check: true
+ ).stdout().strip().split('\n')
+)
+
+test(
+ 'test-server',
+ executable(
+ 'test-server',
+ 'server/object.cpp',
+ server_files,
+ include_directories: [ root_inc, include_directories('server') ],
+ link_with: libsdbusplus,
+ dependencies: [
+ gmock_dep,
+ gmock_main_dep,
+ gtest_dep,
+ libsystemd_pkg,
+ pthread_dep,
+ ],
+ ),
+)
diff --git a/tools/meson.build b/tools/meson.build
new file mode 100644
index 0000000..e9d3a63
--- /dev/null
+++ b/tools/meson.build
@@ -0,0 +1,2 @@
+sdbusplusplus_prog = find_program('sdbus++')
+sdbusgen_prog = find_program('sdbus++-gendir')