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