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