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 17build_tests = get_option('tests') 18 19libevdev = dependency('libevdev') 20libsystemd = dependency('libsystemd') 21libgpiod = dependency('libgpiod') 22phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces') 23phosphor_logging = dependency('phosphor-logging') 24sdbusplus = dependency('sdbusplus') 25systemd = dependency('systemd') 26 27if 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 45boost_args = ['-DBOOST_ASIO_DISABLE_THREADS', 46 '-DBOOST_ERROR_CODE_HEADER_ONLY', 47 '-DBOOST_SYSTEM_NO_DEPRECATED'] 48 49systemd_system_unit_dir = systemd.get_variable( 50 'systemdsystemunitdir', 51 pkgconfig_define: ['prefix', get_option('prefix')]) 52 53fs = import('fs') 54fs.copyfile( 55 'phosphor-gpio-monitor@.service', 56 install: true, 57 install_dir: systemd_system_unit_dir 58) 59 60fs.copyfile( 61 'phosphor-multi-gpio-monitor.service', 62 install: true, 63 install_dir: systemd_system_unit_dir 64) 65 66fs.copyfile( 67 'phosphor-gpio-presence@.service', 68 install: true, 69 install_dir: systemd_system_unit_dir 70) 71 72udev = dependency('udev') 73udev_rules_dir = join_paths( 74 udev.get_variable( 75 'udevdir', 76 pkgconfig_define: ['prefix', get_option('prefix')], 77 ), 78 'rules.d', 79) 80 81fs.copyfile( 82 '99-gpio-keys.rules', 83 install: true, 84 install_dir: udev_rules_dir 85) 86 87fs.copyfile( 88 'phosphor-multi-gpio-monitor.json', 89 install: true, 90 install_dir: get_option('datadir') / 'phosphor-gpio-monitor' 91) 92 93libevdev_o = static_library( 94 'libevdev_o', 95 'evdev.cpp', 96 dependencies: [ 97 libevdev, 98 phosphor_dbus_interfaces, 99 phosphor_logging, 100 sdbusplus, 101 ] 102) 103 104libmonitor_o = static_library( 105 'libmonitor_o', 106 'monitor.cpp', 107 dependencies: [ 108 libevdev, 109 libsystemd, 110 phosphor_logging, 111 ], 112 link_with: [ 113 libevdev_o, 114 ], 115) 116 117phosphor_gpio_monitor = executable( 118 'phosphor-gpio-monitor', 119 'mainapp.cpp', 120 dependencies: [ 121 libevdev, 122 libsystemd, 123 phosphor_logging, 124 ], 125 install: true, 126 link_with: [ 127 libevdev_o, 128 libmonitor_o, 129 ], 130) 131 132executable( 133 'phosphor-multi-gpio-monitor', 134 'gpioMonMain.cpp', 135 'gpioMon.cpp', 136 dependencies: [ 137 cli11_dep, 138 libgpiod, 139 nlohmann_json_dep, 140 phosphor_logging, 141 sdbusplus, 142 ], 143 cpp_args: boost_args, 144 install: true, 145) 146 147subdir('presence') 148subdir('test') 149