xref: /openbmc/dbus-sensors/meson.build (revision dabd48dd)
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
14# Note, there is currently an issue with CPUSensor when used in conjunction
15# with io_uring.  For the moment, we enable uring for all other daemons, but
16# we'd like to enable it for all daemons.
17# https://github.com/openbmc/dbus-sensors/issues/19
18uring_args = [
19    '-DBOOST_ASIO_HAS_IO_URING',
20    '-DBOOST_ASIO_DISABLE_EPOLL',
21    '-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT',
22]
23
24add_project_arguments(
25    '-Wno-psabi',
26    '-Wuninitialized',
27    '-DBOOST_SYSTEM_NO_DEPRECATED',
28    '-DBOOST_ERROR_CODE_HEADER_ONLY',
29    '-DBOOST_NO_RTTI',
30    '-DBOOST_NO_TYPEID',
31    '-DBOOST_ALL_NO_LIB',
32    '-DBOOST_ASIO_DISABLE_THREADS',
33    '-DBOOST_ALLOW_DEPRECATED_HEADERS',
34    language: 'cpp',
35)
36
37cpp = meson.get_compiler('cpp')
38
39build_tests = get_option('tests')
40gpiodcxx = dependency('libgpiodcxx',
41    default_options: ['bindings=cxx'],
42)
43
44# i2c-tools doesn't ship a pkg-config file for libi2c
45i2c = meson.get_compiler('cpp').find_library('i2c')
46
47sdbusplus = dependency('sdbusplus', required : false, include_type: 'system')
48if not sdbusplus.found()
49  sdbusplus_proj = subproject('sdbusplus', required: true)
50  sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
51  sdbusplus = sdbusplus.as_system('system')
52endif
53
54phosphor_logging_dep = dependency('phosphor-logging')
55
56if cpp.has_header('nlohmann/json.hpp')
57    nlohmann_json = declare_dependency()
58else
59    nlohmann_json = dependency('nlohmann_json')
60endif
61
62systemd = dependency('systemd')
63systemd_system_unit_dir = systemd.get_variable(
64    pkgconfig: 'systemdsystemunitdir',
65    pkgconfig_define: ['prefix', get_option('prefix')])
66threads = dependency('threads')
67
68boost = dependency('boost',version : '>=1.79.0', required : false, include_type: 'system')
69if not boost.found()
70  subproject('boost', required: false)
71  boost_inc = include_directories('subprojects/boost_1_79_0/', is_system:true)
72  boost  = declare_dependency(include_directories : boost_inc)
73  boost = boost.as_system('system')
74endif
75
76uring = dependency('liburing', required : false, include_type: 'system')
77if not uring.found()
78  uring_proj = subproject('liburing', required: true)
79  uring = uring_proj.get_variable('uring')
80  uring = uring.as_system('system')
81endif
82
83default_deps = [
84    boost,
85    nlohmann_json,
86    phosphor_logging_dep,
87    sdbusplus,
88    uring,
89]
90
91thresholds_a = static_library(
92    'thresholds_a',
93    'src/Thresholds.cpp',
94    dependencies: default_deps,
95    implicit_include_directories: false,
96    include_directories: 'include',
97)
98
99thresholds_dep = declare_dependency(
100    link_with: [ thresholds_a ],
101    dependencies: default_deps,
102)
103
104utils_a = static_library(
105    'utils_a',
106    [
107        'src/FileHandle.cpp',
108        'src/SensorPaths.cpp',
109        'src/Utils.cpp',
110    ],
111    dependencies: default_deps,
112    implicit_include_directories: false,
113    include_directories: 'include',
114)
115
116utils_dep = declare_dependency(
117    link_with: [ utils_a ],
118    dependencies: [ sdbusplus ],
119)
120
121devicemgmt_a = static_library(
122    'devicemgmt_a',
123    [
124        'src/DeviceMgmt.cpp',
125    ],
126    dependencies: default_deps,
127    implicit_include_directories: false,
128    include_directories: 'include',
129)
130
131devicemgmt_dep = declare_dependency(
132    link_with: [ devicemgmt_a ],
133    dependencies: default_deps,
134)
135
136pwmsensor_a = static_library(
137    'pwmsensor_a',
138    'src/PwmSensor.cpp',
139    dependencies: [ default_deps, thresholds_dep ],
140    implicit_include_directories: false,
141    include_directories: 'include',
142)
143
144pwmsensor_dep = declare_dependency(
145    link_with: [ pwmsensor_a ],
146    dependencies: [ default_deps, thresholds_dep ],
147)
148
149subdir('include')
150subdir('service_files')
151subdir('src')
152
153if not build_tests.disabled()
154    subdir('tests')
155endif
156