xref: /openbmc/dbus-sensors/meson.build (revision ab570a60)
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.58.0',
12)
13
14# Enable io_uring for all daemons with below flags.
15#    '-DBOOST_ASIO_HAS_IO_URING',
16#    '-DBOOST_ASIO_DISABLE_EPOLL',
17#    '-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT',
18# Note, there is currently an issue with CPUSensor when used in
19# conjunction with io_uring. So it has not been changed to use
20# random file access. But we'd like to enable it for all daemons.
21# https://github.com/openbmc/dbus-sensors/issues/19
22
23add_project_arguments(
24    '-Wno-psabi',
25    '-Wuninitialized',
26    '-DBOOST_SYSTEM_NO_DEPRECATED',
27    '-DBOOST_ASIO_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    '-DBOOST_ASIO_HAS_IO_URING',
35    '-DBOOST_ASIO_DISABLE_EPOLL',
36    '-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT',
37    language: 'cpp',
38)
39
40cpp = meson.get_compiler('cpp')
41
42build_tests = get_option('tests')
43gpiodcxx = dependency('libgpiodcxx',
44    default_options: ['bindings=cxx'],
45)
46
47# i2c-tools doesn't ship a pkg-config file for libi2c
48i2c = meson.get_compiler('cpp').find_library('i2c')
49
50sdbusplus = dependency('sdbusplus', required : false, include_type: 'system')
51if not sdbusplus.found()
52  sdbusplus_proj = subproject('sdbusplus', required: true)
53  sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
54  sdbusplus = sdbusplus.as_system('system')
55endif
56
57phosphor_logging_dep = dependency('phosphor-logging')
58nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
59
60systemd = dependency('systemd')
61systemd_system_unit_dir = systemd.get_variable(
62    'systemdsystemunitdir',
63    pkgconfig_define: ['prefix', get_option('prefix')])
64threads = dependency('threads')
65
66boost = dependency('boost',version : '>=1.79.0', required : false, include_type: 'system')
67if not boost.found()
68  subproject('boost', required: false)
69  boost_inc = include_directories('subprojects/boost_1_79_0/', is_system:true)
70  boost  = declare_dependency(include_directories : boost_inc)
71  boost = boost.as_system('system')
72endif
73
74uring = dependency('liburing', required : false, include_type: 'system')
75if not uring.found()
76  uring_proj = subproject('liburing', required: true)
77  uring = uring_proj.get_variable('uring')
78  uring = uring.as_system('system')
79endif
80
81default_deps = [
82    boost,
83    nlohmann_json_dep,
84    phosphor_logging_dep,
85    sdbusplus,
86    uring,
87]
88
89subdir('service_files')
90subdir('src')
91
92if not build_tests.disabled()
93    subdir('tests')
94endif
95