xref: /openbmc/phosphor-hwmon/meson.build (revision d3e8794e)
1project(
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
13build_tests = get_option('tests')
14
15fmt = dependency('fmt')
16gmock = dependency('gmock')
17gtest = dependency('gtest', main: true)
18
19conf = configuration_data()
20conf.set_quoted('BUSNAME_PREFIX', get_option('busname-prefix'))
21conf.set_quoted('SENSOR_ROOT', get_option('sensor-root'))
22conf.set10('NEGATIVE_ERRNO_ON_FAIL', get_option('negative-errno-on-fail'))
23conf.set10('UPDATE_FUNCTIONAL_ON_FAIL', get_option('update-functional-on-fail'))
24
25sysfs_headers = include_directories('.')
26
27sysfs_deps = [
28    fmt,
29]
30
31sysfs_lib = static_library(
32    'sysfs',
33    'sysfs.cpp',
34    include_directories: sysfs_headers,
35    dependencies: sysfs_deps)
36
37sysfs_dep = declare_dependency(
38    dependencies: sysfs_deps,
39    include_directories: sysfs_headers,
40    link_with: sysfs_lib)
41
42hwmon_headers = include_directories('.')
43
44hwmon_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
55hwmon_lib = static_library(
56    'hwmon',
57    'average.cpp',
58    configure_file(output: 'config.h', configuration: conf),
59    'env.cpp',
60    'fan_pwm.cpp',
61    'fan_speed.cpp',
62    'gpio_handle.cpp',
63    'hwmon.cpp',
64    'hwmonio.cpp',
65    'mainloop.cpp',
66    'sensor.cpp',
67    'sensorset.cpp',
68    dependencies: hwmon_deps,
69    include_directories: hwmon_headers)
70
71hwmon_dep = declare_dependency(
72    dependencies: hwmon_deps,
73    include_directories: hwmon_headers,
74    link_with: hwmon_lib)
75
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.
78cli11_dep = dependency('cli11', required: false)
79has_cli11 = meson.get_compiler('cpp').has_header_symbol(
80    'CLI/CLI.hpp',
81    'CLI::App',
82    dependencies: cli11_dep,
83    required: false)
84if 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')
88endif
89
90executable(
91    'phosphor-hwmon-readd',
92    'readd.cpp',
93    dependencies: [
94        cli11_dep,
95        hwmon_dep,
96    ],
97    install: true)
98
99subdir('msl')
100subdir('test')
101subdir('tools')
102