blob: 8c1183f923e4f1a0921c34ac0198a1b7180da8fe [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 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
Vijay Khemka939a6432019-10-09 17:45:45 -070033boost_args = ['-DBOOST_ASIO_DISABLE_THREADS',
34 '-DBOOST_ERROR_CODE_HEADER_ONLY',
35 '-DBOOST_SYSTEM_NO_DEPRECATED']
36
Konstantin Aladyshev9f8459a2024-04-22 17:56:53 +030037boost_dep = dependency('boost')
38
Patrick Williams0c60faa2023-04-12 08:05:56 -050039systemd_system_unit_dir = systemd.get_variable(
Brad Bishop26373ab2019-09-19 17:18:57 -040040 'systemdsystemunitdir',
Patrick Williams0c60faa2023-04-12 08:05:56 -050041 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishop26373ab2019-09-19 17:18:57 -040042
George Liu1c0e4ea2023-08-03 11:11:13 +080043fs = import('fs')
44fs.copyfile(
45 'phosphor-gpio-monitor@.service',
Brad Bishop26373ab2019-09-19 17:18:57 -040046 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080047 install_dir: systemd_system_unit_dir
Brad Bishop26373ab2019-09-19 17:18:57 -040048)
49
George Liu1c0e4ea2023-08-03 11:11:13 +080050fs.copyfile(
51 'phosphor-multi-gpio-monitor.service',
Vijay Khemkad34bd962019-10-29 12:28:07 -070052 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080053 install_dir: systemd_system_unit_dir
Vijay Khemkad34bd962019-10-29 12:28:07 -070054)
55
George Liu1c0e4ea2023-08-03 11:11:13 +080056fs.copyfile(
Patrick Rudolph46a9a5b2023-08-10 18:32:05 +020057 'phosphor-multi-gpio-presence.service',
58 install: true,
59 install_dir: systemd_system_unit_dir
60)
61
62fs.copyfile(
George Liu1c0e4ea2023-08-03 11:11:13 +080063 'phosphor-gpio-presence@.service',
Brad Bishop26373ab2019-09-19 17:18:57 -040064 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080065 install_dir: systemd_system_unit_dir
Brad Bishop26373ab2019-09-19 17:18:57 -040066)
Brad Bishop2d66b512019-09-19 16:36:47 -040067
Alvin Wang58dc2772019-11-06 13:35:13 +080068udev = dependency('udev')
69udev_rules_dir = join_paths(
Patrick Williams0c60faa2023-04-12 08:05:56 -050070 udev.get_variable(
Alvin Wang58dc2772019-11-06 13:35:13 +080071 'udevdir',
Patrick Williams0c60faa2023-04-12 08:05:56 -050072 pkgconfig_define: ['prefix', get_option('prefix')],
Alvin Wang58dc2772019-11-06 13:35:13 +080073 ),
74 'rules.d',
75)
76
George Liu1c0e4ea2023-08-03 11:11:13 +080077fs.copyfile(
78 '99-gpio-keys.rules',
Alvin Wang58dc2772019-11-06 13:35:13 +080079 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080080 install_dir: udev_rules_dir
Alvin Wang58dc2772019-11-06 13:35:13 +080081)
82
George Liu1c0e4ea2023-08-03 11:11:13 +080083fs.copyfile(
84 'phosphor-multi-gpio-monitor.json',
Vijay Khemkad34bd962019-10-29 12:28:07 -070085 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080086 install_dir: get_option('datadir') / 'phosphor-gpio-monitor'
Vijay Khemkad34bd962019-10-29 12:28:07 -070087)
88
Brad Bishop2d66b512019-09-19 16:36:47 -040089libevdev_o = static_library(
90 'libevdev_o',
91 'evdev.cpp',
92 dependencies: [
93 libevdev,
94 phosphor_dbus_interfaces,
95 phosphor_logging,
96 sdbusplus,
97 ]
98)
99
100libmonitor_o = static_library(
101 'libmonitor_o',
102 'monitor.cpp',
103 dependencies: [
104 libevdev,
105 libsystemd,
106 phosphor_logging,
107 ],
108 link_with: [
109 libevdev_o,
110 ],
111)
112
113phosphor_gpio_monitor = executable(
114 'phosphor-gpio-monitor',
Brad Bishop2d66b512019-09-19 16:36:47 -0400115 'mainapp.cpp',
116 dependencies: [
Patrick Williams82b81952023-08-09 11:10:25 -0500117 cli11_dep,
Brad Bishop2d66b512019-09-19 16:36:47 -0400118 libevdev,
119 libsystemd,
120 phosphor_logging,
121 ],
122 install: true,
123 link_with: [
124 libevdev_o,
125 libmonitor_o,
126 ],
127)
128
Vijay Khemka939a6432019-10-09 17:45:45 -0700129executable(
130 'phosphor-multi-gpio-monitor',
131 'gpioMonMain.cpp',
132 'gpioMon.cpp',
133 dependencies: [
Patrick Williams01729692023-06-01 09:11:32 -0500134 cli11_dep,
135 libgpiod,
136 nlohmann_json_dep,
Patrick Rudolph46a9a5b2023-08-10 18:32:05 +0200137 phosphor_dbus_interfaces,
Vijay Khemka939a6432019-10-09 17:45:45 -0700138 phosphor_logging,
139 sdbusplus,
Konstantin Aladyshev9f8459a2024-04-22 17:56:53 +0300140 boost_dep
Vijay Khemka939a6432019-10-09 17:45:45 -0700141 ],
142 cpp_args: boost_args,
143 install: true,
144)
145
Brad Bishop2d66b512019-09-19 16:36:47 -0400146subdir('presence')
Patrick Rudolph46a9a5b2023-08-10 18:32:05 +0200147subdir('multi-presence')
George Liubf055282023-08-03 14:51:31 +0800148
149build_tests = get_option('tests')
150if build_tests.allowed()
151 subdir('test')
152endif