blob: 0148a0ccc59b424dad58a2a419fe5f7e21b199c7 [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',
Brandon Wymanca2637e2021-03-04 12:41:21 -06008 '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 Williams01729692023-06-01 09:11:32 -050025if cxx.has_header('nlohmann/json.hpp')
26 nlohmann_json_dep = declare_dependency()
27else
28 subproject('nlohmann', required: false)
29 nlohmann_json_dep = declare_dependency(
30 include_directories: [
31 'subprojects/nlohmann-json/single_include',
32 'subprojects/nlohmann-json/single_include/nlohmann',
33 ]
34 )
35endif
36
37if cxx.has_header('CLI/CLI.hpp')
38 cli11_dep = declare_dependency()
39else
40 cli11_dep = dependency('CLI11')
41endif
42
Vijay Khemka939a6432019-10-09 17:45:45 -070043boost_args = ['-DBOOST_ASIO_DISABLE_THREADS',
44 '-DBOOST_ERROR_CODE_HEADER_ONLY',
45 '-DBOOST_SYSTEM_NO_DEPRECATED']
46
Patrick Williams0c60faa2023-04-12 08:05:56 -050047systemd_system_unit_dir = systemd.get_variable(
Brad Bishop26373ab2019-09-19 17:18:57 -040048 'systemdsystemunitdir',
Patrick Williams0c60faa2023-04-12 08:05:56 -050049 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishop26373ab2019-09-19 17:18:57 -040050
George Liu1c0e4ea2023-08-03 11:11:13 +080051fs = import('fs')
52fs.copyfile(
53 'phosphor-gpio-monitor@.service',
Brad Bishop26373ab2019-09-19 17:18:57 -040054 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080055 install_dir: systemd_system_unit_dir
Brad Bishop26373ab2019-09-19 17:18:57 -040056)
57
George Liu1c0e4ea2023-08-03 11:11:13 +080058fs.copyfile(
59 'phosphor-multi-gpio-monitor.service',
Vijay Khemkad34bd962019-10-29 12:28:07 -070060 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080061 install_dir: systemd_system_unit_dir
Vijay Khemkad34bd962019-10-29 12:28:07 -070062)
63
George Liu1c0e4ea2023-08-03 11:11:13 +080064fs.copyfile(
Patrick Rudolph46a9a5b2023-08-10 18:32:05 +020065 'phosphor-multi-gpio-presence.service',
66 install: true,
67 install_dir: systemd_system_unit_dir
68)
69
70fs.copyfile(
George Liu1c0e4ea2023-08-03 11:11:13 +080071 'phosphor-gpio-presence@.service',
Brad Bishop26373ab2019-09-19 17:18:57 -040072 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080073 install_dir: systemd_system_unit_dir
Brad Bishop26373ab2019-09-19 17:18:57 -040074)
Brad Bishop2d66b512019-09-19 16:36:47 -040075
Alvin Wang58dc2772019-11-06 13:35:13 +080076udev = dependency('udev')
77udev_rules_dir = join_paths(
Patrick Williams0c60faa2023-04-12 08:05:56 -050078 udev.get_variable(
Alvin Wang58dc2772019-11-06 13:35:13 +080079 'udevdir',
Patrick Williams0c60faa2023-04-12 08:05:56 -050080 pkgconfig_define: ['prefix', get_option('prefix')],
Alvin Wang58dc2772019-11-06 13:35:13 +080081 ),
82 'rules.d',
83)
84
George Liu1c0e4ea2023-08-03 11:11:13 +080085fs.copyfile(
86 '99-gpio-keys.rules',
Alvin Wang58dc2772019-11-06 13:35:13 +080087 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080088 install_dir: udev_rules_dir
Alvin Wang58dc2772019-11-06 13:35:13 +080089)
90
George Liu1c0e4ea2023-08-03 11:11:13 +080091fs.copyfile(
92 'phosphor-multi-gpio-monitor.json',
Vijay Khemkad34bd962019-10-29 12:28:07 -070093 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080094 install_dir: get_option('datadir') / 'phosphor-gpio-monitor'
Vijay Khemkad34bd962019-10-29 12:28:07 -070095)
96
Brad Bishop2d66b512019-09-19 16:36:47 -040097libevdev_o = static_library(
98 'libevdev_o',
99 'evdev.cpp',
100 dependencies: [
101 libevdev,
102 phosphor_dbus_interfaces,
103 phosphor_logging,
104 sdbusplus,
105 ]
106)
107
108libmonitor_o = static_library(
109 'libmonitor_o',
110 'monitor.cpp',
111 dependencies: [
112 libevdev,
113 libsystemd,
114 phosphor_logging,
115 ],
116 link_with: [
117 libevdev_o,
118 ],
119)
120
121phosphor_gpio_monitor = executable(
122 'phosphor-gpio-monitor',
Brad Bishop2d66b512019-09-19 16:36:47 -0400123 'mainapp.cpp',
124 dependencies: [
Patrick Williams82b81952023-08-09 11:10:25 -0500125 cli11_dep,
Brad Bishop2d66b512019-09-19 16:36:47 -0400126 libevdev,
127 libsystemd,
128 phosphor_logging,
129 ],
130 install: true,
131 link_with: [
132 libevdev_o,
133 libmonitor_o,
134 ],
135)
136
Vijay Khemka939a6432019-10-09 17:45:45 -0700137executable(
138 'phosphor-multi-gpio-monitor',
139 'gpioMonMain.cpp',
140 'gpioMon.cpp',
141 dependencies: [
Patrick Williams01729692023-06-01 09:11:32 -0500142 cli11_dep,
143 libgpiod,
144 nlohmann_json_dep,
Patrick Rudolph46a9a5b2023-08-10 18:32:05 +0200145 phosphor_dbus_interfaces,
Vijay Khemka939a6432019-10-09 17:45:45 -0700146 phosphor_logging,
147 sdbusplus,
Vijay Khemka939a6432019-10-09 17:45:45 -0700148 ],
149 cpp_args: boost_args,
150 install: true,
151)
152
Brad Bishop2d66b512019-09-19 16:36:47 -0400153subdir('presence')
Patrick Rudolph46a9a5b2023-08-10 18:32:05 +0200154subdir('multi-presence')
George Liubf055282023-08-03 14:51:31 +0800155
156build_tests = get_option('tests')
157if build_tests.allowed()
158 subdir('test')
159endif