Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-hwmon', |
| 3 | 'cpp', |
| 4 | default_options: [ |
| 5 | 'warning_level=3', |
| 6 | 'werror=true', |
Patrick Williams | 3a81614 | 2021-10-06 15:36:42 -0500 | [diff] [blame] | 7 | 'cpp_std=c++20' |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 8 | ], |
| 9 | license: 'Apache-2.0', |
| 10 | version: '1.0', |
Patrick Williams | 3a81614 | 2021-10-06 15:36:42 -0500 | [diff] [blame] | 11 | meson_version: '>=0.57.0', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 12 | ) |
| 13 | |
Matt Spinler | 5e034af | 2020-06-24 15:21:53 -0500 | [diff] [blame] | 14 | fmt = dependency('fmt') |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 15 | |
| 16 | conf = configuration_data() |
| 17 | conf.set_quoted('BUSNAME_PREFIX', get_option('busname-prefix')) |
| 18 | conf.set_quoted('SENSOR_ROOT', get_option('sensor-root')) |
| 19 | conf.set10('NEGATIVE_ERRNO_ON_FAIL', get_option('negative-errno-on-fail')) |
| 20 | conf.set10('UPDATE_FUNCTIONAL_ON_FAIL', get_option('update-functional-on-fail')) |
| 21 | |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 22 | sysfs_headers = include_directories('.') |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 23 | |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 24 | sysfs_deps = [ |
| 25 | fmt, |
| 26 | ] |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 27 | |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 28 | sysfs_lib = static_library( |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 29 | 'sysfs', |
| 30 | 'sysfs.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 31 | include_directories: sysfs_headers, |
| 32 | dependencies: sysfs_deps) |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 33 | |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 34 | sysfs_dep = declare_dependency( |
| 35 | dependencies: sysfs_deps, |
| 36 | include_directories: sysfs_headers, |
| 37 | link_with: sysfs_lib) |
| 38 | |
| 39 | hwmon_headers = include_directories('.') |
| 40 | |
| 41 | hwmon_deps = [ |
| 42 | fmt, |
| 43 | dependency('gpioplus'), |
| 44 | dependency('phosphor-dbus-interfaces'), |
| 45 | dependency('phosphor-logging'), |
| 46 | dependency('sdbusplus'), |
| 47 | dependency('sdeventplus'), |
| 48 | dependency('stdplus'), |
Brandon Kim | 6d50c3e | 2019-08-09 15:38:53 -0700 | [diff] [blame] | 49 | dependency('threads'), |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 50 | sysfs_dep, |
| 51 | ] |
| 52 | |
| 53 | hwmon_lib = static_library( |
| 54 | 'hwmon', |
| 55 | 'average.cpp', |
| 56 | configure_file(output: 'config.h', configuration: conf), |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 57 | 'env.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 58 | 'fan_pwm.cpp', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 59 | 'fan_speed.cpp', |
| 60 | 'gpio_handle.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 61 | 'hwmon.cpp', |
| 62 | 'hwmonio.cpp', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 63 | 'mainloop.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 64 | 'sensor.cpp', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 65 | 'sensorset.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 66 | dependencies: hwmon_deps, |
| 67 | include_directories: hwmon_headers) |
| 68 | |
| 69 | hwmon_dep = declare_dependency( |
| 70 | dependencies: hwmon_deps, |
| 71 | include_directories: hwmon_headers, |
| 72 | link_with: hwmon_lib) |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 73 | |
William A. Kennington III | d3e8794 | 2021-05-05 12:26:53 -0700 | [diff] [blame] | 74 | # CLI11 might not have a pkg-config. It is header only so just make |
| 75 | # sure we can access the needed symbols from the header. |
| 76 | cli11_dep = dependency('cli11', required: false) |
| 77 | has_cli11 = meson.get_compiler('cpp').has_header_symbol( |
| 78 | 'CLI/CLI.hpp', |
| 79 | 'CLI::App', |
| 80 | dependencies: cli11_dep, |
| 81 | required: false) |
| 82 | if not has_cli11 |
| 83 | cli11_proj = subproject('cli11', required: false) |
| 84 | assert(cli11_proj.found(), 'CLI11 is required') |
| 85 | cli11_dep = cli11_proj.get_variable('CLI11_dep') |
| 86 | endif |
| 87 | |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 88 | executable( |
| 89 | 'phosphor-hwmon-readd', |
| 90 | 'readd.cpp', |
William A. Kennington III | d3e8794 | 2021-05-05 12:26:53 -0700 | [diff] [blame] | 91 | dependencies: [ |
| 92 | cli11_dep, |
| 93 | hwmon_dep, |
| 94 | ], |
| 95 | install: true) |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 96 | |
Anton D. Kachalov | 5b520cf | 2021-02-03 23:19:39 +0100 | [diff] [blame] | 97 | systemd_system_unit_dir = dependency('systemd').get_pkgconfig_variable( |
| 98 | 'systemdsystemunitdir', |
| 99 | define_variable: ['prefix', get_option('prefix')]) |
| 100 | udev_dir = dependency('udev').get_pkgconfig_variable( |
| 101 | 'udev_dir', |
| 102 | define_variable: ['prefix', get_option('prefix')]) |
| 103 | |
| 104 | install_data( |
| 105 | 'xyz.openbmc_project.Hwmon@.service', |
| 106 | install_dir: systemd_system_unit_dir |
| 107 | ) |
| 108 | |
| 109 | install_data( |
| 110 | 'phosphor-hwmon.conf', |
| 111 | install_dir: get_option('sysconfdir') / 'dbus-1/system.d' |
| 112 | ) |
| 113 | |
| 114 | install_data( |
| 115 | ['70-hwmon.rules', '70-iio.rules'], |
| 116 | install_dir: udev_dir / 'rules.d' |
| 117 | ) |
| 118 | |
| 119 | install_data( |
| 120 | 'start_hwmon.sh', |
| 121 | install_dir: get_option('bindir'), |
| 122 | install_mode: 'rwxr-xr-x' |
| 123 | ) |
| 124 | |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 125 | subdir('msl') |
William A. Kennington III | bb25973 | 2021-05-05 12:35:01 -0700 | [diff] [blame] | 126 | if not get_option('tests').disabled() |
| 127 | subdir('test') |
| 128 | endif |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 129 | subdir('tools') |