xref: /openbmc/dbus-sensors/meson.build (revision 3f556a84)
1project(
2    'dbus-sensors',
3    'cpp',
4    default_options: [
5        'warning_level=3',
6        'werror=true',
7        'cpp_std=c++20'
8    ],
9    license: 'Apache-2.0',
10    version: '0.1',
11    meson_version: '>=0.57.0',
12)
13
14add_project_arguments(
15    '-Wno-psabi',
16    '-Wuninitialized',
17    '-DBOOST_SYSTEM_NO_DEPRECATED',
18    '-DBOOST_ERROR_CODE_HEADER_ONLY',
19    '-DBOOST_NO_RTTI',
20    '-DBOOST_NO_TYPEID',
21    '-DBOOST_ALL_NO_LIB',
22    '-DBOOST_ASIO_DISABLE_THREADS',
23    '-DBOOST_ALLOW_DEPRECATED_HEADERS',
24    language: 'cpp',
25)
26
27cpp = meson.get_compiler('cpp')
28
29build_tests = get_option('tests')
30gpiodcxx = dependency('libgpiodcxx',
31    default_options: ['bindings=cxx'],
32)
33
34# i2c-tools doesn't ship a pkg-config file for libi2c
35i2c = meson.get_compiler('cpp').find_library('i2c')
36
37sdbusplus = dependency('sdbusplus')
38phosphor_logging_dep = dependency('phosphor-logging')
39
40if cpp.has_header('nlohmann/json.hpp')
41    nlohmann_json = declare_dependency()
42else
43    nlohmann_json = dependency('nlohmann_json')
44endif
45
46systemd = dependency('systemd')
47systemd_system_unit_dir = systemd.get_variable(
48    pkgconfig: 'systemdsystemunitdir',
49    pkgconfig_define: ['prefix', get_option('prefix')])
50threads = dependency('threads')
51
52default_deps = [
53    nlohmann_json,
54    phosphor_logging_dep,
55    sdbusplus,
56]
57
58thresholds_a = static_library(
59    'thresholds_a',
60    'src/Thresholds.cpp',
61    dependencies: default_deps,
62    implicit_include_directories: false,
63    include_directories: 'include',
64)
65
66thresholds_dep = declare_dependency(
67    link_with: [ thresholds_a ],
68    dependencies: default_deps,
69)
70
71utils_a = static_library(
72    'utils_a',
73    [
74        'src/FileHandle.cpp',
75        'src/SensorPaths.cpp',
76        'src/Utils.cpp',
77    ],
78    dependencies: default_deps,
79    implicit_include_directories: false,
80    include_directories: 'include',
81)
82
83utils_dep = declare_dependency(
84    link_with: [ utils_a ],
85    dependencies: [ sdbusplus ],
86)
87
88pwmsensor_a = static_library(
89    'pwmsensor_a',
90    'src/PwmSensor.cpp',
91    dependencies: [ default_deps, thresholds_dep ],
92    implicit_include_directories: false,
93    include_directories: 'include',
94)
95
96pwmsensor_dep = declare_dependency(
97    link_with: [ pwmsensor_a ],
98    dependencies: [ default_deps, thresholds_dep ],
99)
100
101subdir('include')
102subdir('service_files')
103subdir('src')
104
105if not build_tests.disabled()
106    subdir('tests')
107endif
108