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 | |
| 13 | build_tests = get_option('tests') |
| 14 | |
Matt Spinler | 5e034af | 2020-06-24 15:21:53 -0500 | [diff] [blame] | 15 | fmt = dependency('fmt') |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 16 | gmock = dependency('gmock') |
| 17 | gtest = dependency('gtest', main: true) |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 18 | |
| 19 | conf = configuration_data() |
| 20 | conf.set_quoted('BUSNAME_PREFIX', get_option('busname-prefix')) |
| 21 | conf.set_quoted('SENSOR_ROOT', get_option('sensor-root')) |
| 22 | conf.set10('NEGATIVE_ERRNO_ON_FAIL', get_option('negative-errno-on-fail')) |
| 23 | conf.set10('UPDATE_FUNCTIONAL_ON_FAIL', get_option('update-functional-on-fail')) |
| 24 | |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 25 | sysfs_headers = include_directories('.') |
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_deps = [ |
| 28 | fmt, |
| 29 | ] |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 30 | |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 31 | sysfs_lib = static_library( |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 32 | 'sysfs', |
| 33 | 'sysfs.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 34 | include_directories: sysfs_headers, |
| 35 | dependencies: sysfs_deps) |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 36 | |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 37 | sysfs_dep = declare_dependency( |
| 38 | dependencies: sysfs_deps, |
| 39 | include_directories: sysfs_headers, |
| 40 | link_with: sysfs_lib) |
| 41 | |
| 42 | hwmon_headers = include_directories('.') |
| 43 | |
| 44 | hwmon_deps = [ |
| 45 | fmt, |
| 46 | dependency('gpioplus'), |
| 47 | dependency('phosphor-dbus-interfaces'), |
| 48 | dependency('phosphor-logging'), |
| 49 | dependency('sdbusplus'), |
| 50 | dependency('sdeventplus'), |
| 51 | dependency('stdplus'), |
| 52 | sysfs_dep, |
| 53 | ] |
| 54 | |
| 55 | hwmon_lib = static_library( |
| 56 | 'hwmon', |
| 57 | 'average.cpp', |
| 58 | configure_file(output: 'config.h', configuration: conf), |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 59 | 'env.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 60 | 'fan_pwm.cpp', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 61 | 'fan_speed.cpp', |
| 62 | 'gpio_handle.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 63 | 'hwmon.cpp', |
| 64 | 'hwmonio.cpp', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 65 | 'mainloop.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 66 | 'sensor.cpp', |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 67 | 'sensorset.cpp', |
William A. Kennington III | f9aff80 | 2021-05-05 12:06:24 -0700 | [diff] [blame] | 68 | dependencies: hwmon_deps, |
| 69 | include_directories: hwmon_headers) |
| 70 | |
| 71 | hwmon_dep = declare_dependency( |
| 72 | dependencies: hwmon_deps, |
| 73 | include_directories: hwmon_headers, |
| 74 | link_with: hwmon_lib) |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 75 | |
William A. Kennington III | d3e8794 | 2021-05-05 12:26:53 -0700 | [diff] [blame^] | 76 | # CLI11 might not have a pkg-config. It is header only so just make |
| 77 | # sure we can access the needed symbols from the header. |
| 78 | cli11_dep = dependency('cli11', required: false) |
| 79 | has_cli11 = meson.get_compiler('cpp').has_header_symbol( |
| 80 | 'CLI/CLI.hpp', |
| 81 | 'CLI::App', |
| 82 | dependencies: cli11_dep, |
| 83 | required: false) |
| 84 | if not has_cli11 |
| 85 | cli11_proj = subproject('cli11', required: false) |
| 86 | assert(cli11_proj.found(), 'CLI11 is required') |
| 87 | cli11_dep = cli11_proj.get_variable('CLI11_dep') |
| 88 | endif |
| 89 | |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 90 | executable( |
| 91 | 'phosphor-hwmon-readd', |
| 92 | 'readd.cpp', |
William A. Kennington III | d3e8794 | 2021-05-05 12:26:53 -0700 | [diff] [blame^] | 93 | dependencies: [ |
| 94 | cli11_dep, |
| 95 | hwmon_dep, |
| 96 | ], |
| 97 | install: true) |
Brad Bishop | 5906173 | 2019-10-07 15:48:37 -0400 | [diff] [blame] | 98 | |
| 99 | subdir('msl') |
| 100 | subdir('test') |
| 101 | subdir('tools') |