blob: a3f3badd29e2b6d3929fef569d5c6aad6e40d919 [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 -040017build_tests = get_option('tests')
18
Brad Bishop2d66b512019-09-19 16:36:47 -040019libevdev = dependency('libevdev')
20libsystemd = dependency('libsystemd')
Vijay Khemka939a6432019-10-09 17:45:45 -070021libgpiod = dependency('libgpiod')
Brad Bishop2d66b512019-09-19 16:36:47 -040022phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
23phosphor_logging = dependency('phosphor-logging')
24sdbusplus = dependency('sdbusplus')
Brad Bishop26373ab2019-09-19 17:18:57 -040025systemd = dependency('systemd')
26
Patrick Williams01729692023-06-01 09:11:32 -050027if cxx.has_header('nlohmann/json.hpp')
28 nlohmann_json_dep = declare_dependency()
29else
30 subproject('nlohmann', required: false)
31 nlohmann_json_dep = declare_dependency(
32 include_directories: [
33 'subprojects/nlohmann-json/single_include',
34 'subprojects/nlohmann-json/single_include/nlohmann',
35 ]
36 )
37endif
38
39if cxx.has_header('CLI/CLI.hpp')
40 cli11_dep = declare_dependency()
41else
42 cli11_dep = dependency('CLI11')
43endif
44
Vijay Khemka939a6432019-10-09 17:45:45 -070045boost_args = ['-DBOOST_ASIO_DISABLE_THREADS',
46 '-DBOOST_ERROR_CODE_HEADER_ONLY',
47 '-DBOOST_SYSTEM_NO_DEPRECATED']
48
Patrick Williams0c60faa2023-04-12 08:05:56 -050049systemd_system_unit_dir = systemd.get_variable(
Brad Bishop26373ab2019-09-19 17:18:57 -040050 'systemdsystemunitdir',
Patrick Williams0c60faa2023-04-12 08:05:56 -050051 pkgconfig_define: ['prefix', get_option('prefix')])
Brad Bishop26373ab2019-09-19 17:18:57 -040052
53configure_file(
54 copy: true,
55 input: 'phosphor-gpio-monitor@.service',
56 install: true,
57 install_dir: systemd_system_unit_dir,
58 output: 'phosphor-gpio-monitor@.service'
59)
60
61configure_file(
62 copy: true,
Vijay Khemkad34bd962019-10-29 12:28:07 -070063 input: 'phosphor-multi-gpio-monitor.service',
64 install: true,
65 install_dir: systemd_system_unit_dir,
66 output: 'phosphor-multi-gpio-monitor.service'
67)
68
69configure_file(
70 copy: true,
Brad Bishop26373ab2019-09-19 17:18:57 -040071 input: 'phosphor-gpio-presence@.service',
72 install: true,
73 install_dir: systemd_system_unit_dir,
74 output: 'phosphor-gpio-presence@.service'
75)
Brad Bishop2d66b512019-09-19 16:36:47 -040076
Alvin Wang58dc2772019-11-06 13:35:13 +080077udev = dependency('udev')
78udev_rules_dir = join_paths(
Patrick Williams0c60faa2023-04-12 08:05:56 -050079 udev.get_variable(
Alvin Wang58dc2772019-11-06 13:35:13 +080080 'udevdir',
Patrick Williams0c60faa2023-04-12 08:05:56 -050081 pkgconfig_define: ['prefix', get_option('prefix')],
Alvin Wang58dc2772019-11-06 13:35:13 +080082 ),
83 'rules.d',
84)
85
86configure_file(
87 copy: true,
88 input: '99-gpio-keys.rules',
89 install: true,
90 install_dir: udev_rules_dir,
91 output: '99-gpio-keys.rules'
92)
93
94
Vijay Khemkad34bd962019-10-29 12:28:07 -070095configure_file(
96 copy: true,
97 input: 'phosphor-multi-gpio-monitor.json',
98 install: true,
99 install_dir: '/usr/share/phosphor-gpio-monitor',
100 output: 'phosphor-multi-gpio-monitor.json'
101)
102
Brad Bishop2d66b512019-09-19 16:36:47 -0400103libevdev_o = static_library(
104 'libevdev_o',
105 'evdev.cpp',
106 dependencies: [
107 libevdev,
108 phosphor_dbus_interfaces,
109 phosphor_logging,
110 sdbusplus,
111 ]
112)
113
114libmonitor_o = static_library(
115 'libmonitor_o',
116 'monitor.cpp',
117 dependencies: [
118 libevdev,
119 libsystemd,
120 phosphor_logging,
121 ],
122 link_with: [
123 libevdev_o,
124 ],
125)
126
127phosphor_gpio_monitor = executable(
128 'phosphor-gpio-monitor',
129 'argument.cpp',
130 'mainapp.cpp',
131 dependencies: [
132 libevdev,
133 libsystemd,
134 phosphor_logging,
135 ],
136 install: true,
137 link_with: [
138 libevdev_o,
139 libmonitor_o,
140 ],
141)
142
Vijay Khemka939a6432019-10-09 17:45:45 -0700143executable(
144 'phosphor-multi-gpio-monitor',
145 'gpioMonMain.cpp',
146 'gpioMon.cpp',
147 dependencies: [
Patrick Williams01729692023-06-01 09:11:32 -0500148 cli11_dep,
149 libgpiod,
150 nlohmann_json_dep,
Vijay Khemka939a6432019-10-09 17:45:45 -0700151 phosphor_logging,
152 sdbusplus,
Vijay Khemka939a6432019-10-09 17:45:45 -0700153 ],
154 cpp_args: boost_args,
155 install: true,
156)
157
Brad Bishop2d66b512019-09-19 16:36:47 -0400158subdir('gpio-util')
159subdir('presence')
160subdir('test')