xref: /openbmc/phosphor-hwmon/meson.build (revision c8e818dd)
1project(
2    'phosphor-hwmon',
3    'cpp',
4    default_options: [
5        'warning_level=3',
6        'werror=true',
7        'cpp_std=c++23'
8    ],
9    license: 'Apache-2.0',
10    version: '1.0',
11    meson_version: '>=1.1.1',
12)
13
14fmt = dependency('fmt')
15
16conf = configuration_data()
17conf.set_quoted('BUSNAME_PREFIX', get_option('busname-prefix'))
18conf.set_quoted('SENSOR_ROOT', get_option('sensor-root'))
19conf.set10('NEGATIVE_ERRNO_ON_FAIL', get_option('negative-errno-on-fail'))
20conf.set10('UPDATE_FUNCTIONAL_ON_FAIL', get_option('update-functional-on-fail'))
21
22sysfs_headers = include_directories('.')
23
24sysfs_deps = [
25    fmt,
26]
27
28sysfs_lib = static_library(
29    'sysfs',
30    'sysfs.cpp',
31    include_directories: sysfs_headers,
32    dependencies: sysfs_deps)
33
34sysfs_dep = declare_dependency(
35    dependencies: sysfs_deps,
36    include_directories: sysfs_headers,
37    link_with: sysfs_lib)
38
39hwmon_headers = include_directories('.')
40
41hwmon_deps = [
42    fmt,
43    dependency('gpioplus'),
44    dependency('phosphor-dbus-interfaces'),
45    dependency('phosphor-logging'),
46    dependency('sdbusplus'),
47    dependency('sdeventplus'),
48    dependency('stdplus'),
49    dependency('threads'),
50    sysfs_dep,
51]
52
53hwmon_lib = static_library(
54    'hwmon',
55    'average.cpp',
56    configure_file(output: 'config.h', configuration: conf),
57    'env.cpp',
58    'fan_pwm.cpp',
59    'fan_speed.cpp',
60    'gpio_handle.cpp',
61    'hwmon.cpp',
62    'hwmonio.cpp',
63    'mainloop.cpp',
64    'sensor.cpp',
65    'sensorset.cpp',
66    dependencies: hwmon_deps,
67    include_directories: hwmon_headers)
68
69hwmon_dep = declare_dependency(
70    dependencies: hwmon_deps,
71    include_directories: hwmon_headers,
72    link_with: hwmon_lib)
73
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.
76cli11_dep = dependency('cli11', required: false)
77has_cli11 = meson.get_compiler('cpp').has_header_symbol(
78    'CLI/CLI.hpp',
79    'CLI::App',
80    dependencies: cli11_dep,
81    required: false)
82if 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')
86endif
87
88executable(
89    'phosphor-hwmon-readd',
90    'readd.cpp',
91    dependencies: [
92        cli11_dep,
93        hwmon_dep,
94    ],
95    install: true)
96
97systemd_system_unit_dir = dependency('systemd').get_variable(
98    'systemdsystemunitdir',
99    pkgconfig_define: ['prefix', get_option('prefix')])
100udev_dir = dependency('udev').get_variable(
101    'udev_dir',
102    pkgconfig_define: ['prefix', get_option('prefix')])
103
104install_data(
105    'xyz.openbmc_project.Hwmon@.service',
106    install_dir: systemd_system_unit_dir
107)
108
109install_data(
110    'phosphor-hwmon.conf',
111    install_dir: get_option('sysconfdir') / 'dbus-1/system.d'
112)
113
114install_data(
115    ['70-hwmon.rules', '70-iio.rules'],
116    install_dir: udev_dir / 'rules.d'
117)
118
119configure_file(
120    input : 'start_hwmon.sh.in',
121    output : 'start_hwmon.sh',
122    configuration: {'OVERRIDE_WITH_DEVPATH': ' '.join(get_option('override-with-devpath'))},
123    install_dir: get_option('bindir'),
124    install_mode: 'rwxr-xr-x',
125    install: true,
126)
127
128subdir('msl')
129if not get_option('tests').disabled()
130  subdir('test')
131endif
132subdir('tools')
133