blob: 53374965f6575d9e3bc214e9c44dcf4b4ae1aab9 [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(
65 'phosphor-gpio-presence@.service',
Brad Bishop26373ab2019-09-19 17:18:57 -040066 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080067 install_dir: systemd_system_unit_dir
Brad Bishop26373ab2019-09-19 17:18:57 -040068)
Brad Bishop2d66b512019-09-19 16:36:47 -040069
Alvin Wang58dc2772019-11-06 13:35:13 +080070udev = dependency('udev')
71udev_rules_dir = join_paths(
Patrick Williams0c60faa2023-04-12 08:05:56 -050072 udev.get_variable(
Alvin Wang58dc2772019-11-06 13:35:13 +080073 'udevdir',
Patrick Williams0c60faa2023-04-12 08:05:56 -050074 pkgconfig_define: ['prefix', get_option('prefix')],
Alvin Wang58dc2772019-11-06 13:35:13 +080075 ),
76 'rules.d',
77)
78
George Liu1c0e4ea2023-08-03 11:11:13 +080079fs.copyfile(
80 '99-gpio-keys.rules',
Alvin Wang58dc2772019-11-06 13:35:13 +080081 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080082 install_dir: udev_rules_dir
Alvin Wang58dc2772019-11-06 13:35:13 +080083)
84
George Liu1c0e4ea2023-08-03 11:11:13 +080085fs.copyfile(
86 'phosphor-multi-gpio-monitor.json',
Vijay Khemkad34bd962019-10-29 12:28:07 -070087 install: true,
George Liu1c0e4ea2023-08-03 11:11:13 +080088 install_dir: get_option('datadir') / 'phosphor-gpio-monitor'
Vijay Khemkad34bd962019-10-29 12:28:07 -070089)
90
Brad Bishop2d66b512019-09-19 16:36:47 -040091libevdev_o = static_library(
92 'libevdev_o',
93 'evdev.cpp',
94 dependencies: [
95 libevdev,
96 phosphor_dbus_interfaces,
97 phosphor_logging,
98 sdbusplus,
99 ]
100)
101
102libmonitor_o = static_library(
103 'libmonitor_o',
104 'monitor.cpp',
105 dependencies: [
106 libevdev,
107 libsystemd,
108 phosphor_logging,
109 ],
110 link_with: [
111 libevdev_o,
112 ],
113)
114
115phosphor_gpio_monitor = executable(
116 'phosphor-gpio-monitor',
Brad Bishop2d66b512019-09-19 16:36:47 -0400117 'mainapp.cpp',
118 dependencies: [
Patrick Williams82b81952023-08-09 11:10:25 -0500119 cli11_dep,
Brad Bishop2d66b512019-09-19 16:36:47 -0400120 libevdev,
121 libsystemd,
122 phosphor_logging,
123 ],
124 install: true,
125 link_with: [
126 libevdev_o,
127 libmonitor_o,
128 ],
129)
130
Vijay Khemka939a6432019-10-09 17:45:45 -0700131executable(
132 'phosphor-multi-gpio-monitor',
133 'gpioMonMain.cpp',
134 'gpioMon.cpp',
135 dependencies: [
Patrick Williams01729692023-06-01 09:11:32 -0500136 cli11_dep,
137 libgpiod,
138 nlohmann_json_dep,
Vijay Khemka939a6432019-10-09 17:45:45 -0700139 phosphor_logging,
140 sdbusplus,
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')
George Liubf055282023-08-03 14:51:31 +0800147
148build_tests = get_option('tests')
149if build_tests.allowed()
150 subdir('test')
151endif