1project( 2 'phosphor-gpio-monitor', 3 'cpp', 4 default_options: [ 5 'warning_level=3', 6 'werror=true', 7 'cpp_std=c++23', 8 'buildtype=debugoptimized' 9 ], 10 license: 'Apache-2.0', 11 version: '1.0', 12 meson_version: '>=1.1.1', 13) 14 15cxx = meson.get_compiler('cpp') 16 17libevdev = dependency('libevdev') 18libsystemd = dependency('libsystemd') 19libgpiod = dependency('libgpiod') 20phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces') 21phosphor_logging = dependency('phosphor-logging') 22sdbusplus = dependency('sdbusplus') 23systemd = dependency('systemd') 24 25if 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 43boost_args = ['-DBOOST_ASIO_DISABLE_THREADS', 44 '-DBOOST_ERROR_CODE_HEADER_ONLY', 45 '-DBOOST_SYSTEM_NO_DEPRECATED'] 46 47systemd_system_unit_dir = systemd.get_variable( 48 'systemdsystemunitdir', 49 pkgconfig_define: ['prefix', get_option('prefix')]) 50 51fs = import('fs') 52fs.copyfile( 53 'phosphor-gpio-monitor@.service', 54 install: true, 55 install_dir: systemd_system_unit_dir 56) 57 58fs.copyfile( 59 'phosphor-multi-gpio-monitor.service', 60 install: true, 61 install_dir: systemd_system_unit_dir 62) 63 64fs.copyfile( 65 'phosphor-multi-gpio-presence.service', 66 install: true, 67 install_dir: systemd_system_unit_dir 68) 69 70fs.copyfile( 71 'phosphor-gpio-presence@.service', 72 install: true, 73 install_dir: systemd_system_unit_dir 74) 75 76udev = dependency('udev') 77udev_rules_dir = join_paths( 78 udev.get_variable( 79 'udevdir', 80 pkgconfig_define: ['prefix', get_option('prefix')], 81 ), 82 'rules.d', 83) 84 85fs.copyfile( 86 '99-gpio-keys.rules', 87 install: true, 88 install_dir: udev_rules_dir 89) 90 91fs.copyfile( 92 'phosphor-multi-gpio-monitor.json', 93 install: true, 94 install_dir: get_option('datadir') / 'phosphor-gpio-monitor' 95) 96 97libevdev_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', 123 'mainapp.cpp', 124 dependencies: [ 125 cli11_dep, 126 libevdev, 127 libsystemd, 128 phosphor_logging, 129 ], 130 install: true, 131 link_with: [ 132 libevdev_o, 133 libmonitor_o, 134 ], 135) 136 137executable( 138 'phosphor-multi-gpio-monitor', 139 'gpioMonMain.cpp', 140 'gpioMon.cpp', 141 dependencies: [ 142 cli11_dep, 143 libgpiod, 144 nlohmann_json_dep, 145 phosphor_dbus_interfaces, 146 phosphor_logging, 147 sdbusplus, 148 ], 149 cpp_args: boost_args, 150 install: true, 151) 152 153subdir('presence') 154subdir('multi-presence') 155 156build_tests = get_option('tests') 157if build_tests.allowed() 158 subdir('test') 159endif 160