blob: c66115d8bb70ba2dfbe1ba5092a881959e93a2ce [file] [log] [blame]
Brad Bishop2d66b512019-09-19 16:36:47 -04001project(
2 'phosphor-gpio-monitor',
3 'cpp',
4 default_options: [
5 'warning_level=3',
6 'werror=true',
Patrick Williamsee1663c2023-07-12 11:15:43 -05007 'cpp_std=c++23',
Patrick Williamsc087fa72025-02-01 08:37:26 -05008 'buildtype=debugoptimized',
Brad Bishop2d66b512019-09-19 16:36:47 -04009 ],
10 license: 'Apache-2.0',
11 version: '1.0',
Patrick Williamsee1663c2023-07-12 11:15:43 -050012 meson_version: '>=1.1.1',
Brad Bishop2d66b512019-09-19 16:36:47 -040013)
14
Patrick Williams01729692023-06-01 09:11:32 -050015cxx = meson.get_compiler('cpp')
16
Brad Bishop2d66b512019-09-19 16:36:47 -040017libevdev = dependency('libevdev')
18libsystemd = dependency('libsystemd')
Vijay Khemka939a6432019-10-09 17:45:45 -070019libgpiod = dependency('libgpiod')
Brad Bishop2d66b512019-09-19 16:36:47 -040020phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
21phosphor_logging = dependency('phosphor-logging')
22sdbusplus = dependency('sdbusplus')
Brad Bishop26373ab2019-09-19 17:18:57 -040023systemd = dependency('systemd')
24
Patrick Williamsccfea222023-12-07 14:36:44 -060025nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
Patrick Williams01729692023-06-01 09:11:32 -050026
27if cxx.has_header('CLI/CLI.hpp')
28 cli11_dep = declare_dependency()
29else
30 cli11_dep = dependency('CLI11')
31endif
32
Patrick Williamsc087fa72025-02-01 08:37:26 -050033boost_args = [
34 '-DBOOST_ASIO_DISABLE_THREADS',
35 '-DBOOST_ERROR_CODE_HEADER_ONLY',
36 '-DBOOST_SYSTEM_NO_DEPRECATED',
37]
Vijay Khemka939a6432019-10-09 17:45:45 -070038
Konstantin Aladyshev9f8459a2024-04-22 17:56:53 +030039boost_dep = dependency('boost')
40
Patrick Williams0c60faa2023-04-12 08:05:56 -050041systemd_system_unit_dir = systemd.get_variable(
Brad Bishop26373ab2019-09-19 17:18:57 -040042 'systemdsystemunitdir',
Patrick Williamsc087fa72025-02-01 08:37:26 -050043 pkgconfig_define: ['prefix', get_option('prefix')],
44)
Brad Bishop26373ab2019-09-19 17:18:57 -040045
George Liu1c0e4ea2023-08-03 11:11:13 +080046fs = import('fs')
47fs.copyfile(
48 'phosphor-gpio-monitor@.service',
Brad Bishop26373ab2019-09-19 17:18:57 -040049 install: true,
Patrick Williamsc087fa72025-02-01 08:37:26 -050050 install_dir: systemd_system_unit_dir,
Brad Bishop26373ab2019-09-19 17:18:57 -040051)
52
George Liu1c0e4ea2023-08-03 11:11:13 +080053fs.copyfile(
54 'phosphor-multi-gpio-monitor.service',
Vijay Khemkad34bd962019-10-29 12:28:07 -070055 install: true,
Patrick Williamsc087fa72025-02-01 08:37:26 -050056 install_dir: systemd_system_unit_dir,
Vijay Khemkad34bd962019-10-29 12:28:07 -070057)
58
George Liu1c0e4ea2023-08-03 11:11:13 +080059fs.copyfile(
Patrick Rudolph46a9a5b2023-08-10 18:32:05 +020060 'phosphor-multi-gpio-presence.service',
61 install: true,
Patrick Williamsc087fa72025-02-01 08:37:26 -050062 install_dir: systemd_system_unit_dir,
Patrick Rudolph46a9a5b2023-08-10 18:32:05 +020063)
64
65fs.copyfile(
George Liu1c0e4ea2023-08-03 11:11:13 +080066 'phosphor-gpio-presence@.service',
Brad Bishop26373ab2019-09-19 17:18:57 -040067 install: true,
Patrick Williamsc087fa72025-02-01 08:37:26 -050068 install_dir: systemd_system_unit_dir,
Brad Bishop26373ab2019-09-19 17:18:57 -040069)
Brad Bishop2d66b512019-09-19 16:36:47 -040070
Alvin Wang58dc2772019-11-06 13:35:13 +080071udev = dependency('udev')
72udev_rules_dir = join_paths(
Patrick Williams0c60faa2023-04-12 08:05:56 -050073 udev.get_variable(
Alvin Wang58dc2772019-11-06 13:35:13 +080074 'udevdir',
Patrick Williams0c60faa2023-04-12 08:05:56 -050075 pkgconfig_define: ['prefix', get_option('prefix')],
Alvin Wang58dc2772019-11-06 13:35:13 +080076 ),
77 'rules.d',
78)
79
Patrick Williamsc087fa72025-02-01 08:37:26 -050080fs.copyfile('99-gpio-keys.rules', install: true, install_dir: udev_rules_dir)
Alvin Wang58dc2772019-11-06 13:35:13 +080081
George Liu1c0e4ea2023-08-03 11:11:13 +080082fs.copyfile(
83 'phosphor-multi-gpio-monitor.json',
Vijay Khemkad34bd962019-10-29 12:28:07 -070084 install: true,
Patrick Williamsc087fa72025-02-01 08:37:26 -050085 install_dir: get_option('datadir') / 'phosphor-gpio-monitor',
Vijay Khemkad34bd962019-10-29 12:28:07 -070086)
87
Brad Bishop2d66b512019-09-19 16:36:47 -040088libevdev_o = static_library(
89 'libevdev_o',
90 'evdev.cpp',
91 dependencies: [
92 libevdev,
93 phosphor_dbus_interfaces,
94 phosphor_logging,
95 sdbusplus,
Patrick Williamsc087fa72025-02-01 08:37:26 -050096 ],
Brad Bishop2d66b512019-09-19 16:36:47 -040097)
98
99libmonitor_o = static_library(
100 'libmonitor_o',
Patrick Williamsc087fa72025-02-01 08:37:26 -0500101 'monitor.cpp',
102 dependencies: [libevdev, libsystemd, phosphor_logging],
103 link_with: [libevdev_o],
Brad Bishop2d66b512019-09-19 16:36:47 -0400104)
105
106phosphor_gpio_monitor = executable(
107 'phosphor-gpio-monitor',
Brad Bishop2d66b512019-09-19 16:36:47 -0400108 'mainapp.cpp',
Patrick Williamsc087fa72025-02-01 08:37:26 -0500109 dependencies: [cli11_dep, libevdev, libsystemd, phosphor_logging],
Brad Bishop2d66b512019-09-19 16:36:47 -0400110 install: true,
Patrick Williamsc087fa72025-02-01 08:37:26 -0500111 link_with: [libevdev_o, libmonitor_o],
Brad Bishop2d66b512019-09-19 16:36:47 -0400112)
113
Vijay Khemka939a6432019-10-09 17:45:45 -0700114executable(
Patrick Williamsc087fa72025-02-01 08:37:26 -0500115 'phosphor-multi-gpio-monitor',
116 'gpioMonMain.cpp',
117 'gpioMon.cpp',
118 dependencies: [
Patrick Williams01729692023-06-01 09:11:32 -0500119 cli11_dep,
120 libgpiod,
121 nlohmann_json_dep,
Patrick Rudolph46a9a5b2023-08-10 18:32:05 +0200122 phosphor_dbus_interfaces,
Vijay Khemka939a6432019-10-09 17:45:45 -0700123 phosphor_logging,
124 sdbusplus,
Patrick Williamsc087fa72025-02-01 08:37:26 -0500125 boost_dep,
Vijay Khemka939a6432019-10-09 17:45:45 -0700126 ],
127 cpp_args: boost_args,
128 install: true,
129)
130
Brad Bishop2d66b512019-09-19 16:36:47 -0400131subdir('presence')
Patrick Rudolph46a9a5b2023-08-10 18:32:05 +0200132subdir('multi-presence')
George Liubf055282023-08-03 14:51:31 +0800133
134build_tests = get_option('tests')
135if build_tests.allowed()
136 subdir('test')
137endif