xref: /openbmc/sdbusplus/meson.build (revision 63190dde0d374ab4d0f0bf8ce8a02543b5c2ce18)
1project(
2    'sdbusplus',
3    'cpp',
4    'c',
5    default_options: [
6        'buildtype=debugoptimized',
7        'cpp_std=c++23',
8        'warning_level=3',
9        'werror=true',
10        'tests=' + (meson.is_subproject() ? 'disabled' : 'auto'),
11        'examples=' + (meson.is_subproject() ? 'disabled' : 'auto'),
12    ],
13    version: '1.0.0',
14    meson_version: '>=1.1.1',
15)
16cxx = meson.get_compiler('cpp')
17if (cxx.get_id() == 'clang')
18    add_project_arguments(['-Wno-c++26-extensions'], language: 'cpp')
19endif
20
21libsystemd_pkg = dependency('libsystemd')
22nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
23
24python = import('python')
25python_bin = python.find_installation(
26    'python3',
27    modules: ['inflection', 'yaml', 'mako'],
28)
29
30if not python_bin.found()
31    error('No valid python3 installation found')
32endif
33
34root_inc = include_directories('include')
35
36libsdbusplus_src = files(
37    'src/async/context.cpp',
38    'src/async/fdio.cpp',
39    'src/async/match.cpp',
40    'src/bus.cpp',
41    'src/bus/match.cpp',
42    'src/event.cpp',
43    'src/exception.cpp',
44    'src/message/native_types.cpp',
45    'src/sdbus.cpp',
46    'src/server/interface.cpp',
47    'src/server/transaction.cpp',
48)
49
50libsdbusplus = library(
51    'sdbusplus',
52    libsdbusplus_src,
53    include_directories: root_inc,
54    dependencies: [libsystemd_pkg, nlohmann_json_dep],
55    version: meson.project_version(),
56    install: true,
57)
58
59boost_compile_args = [
60    '-DBOOST_ASIO_DISABLE_THREADS',
61    '-DBOOST_ALL_NO_LIB',
62    '-DBOOST_SYSTEM_NO_DEPRECATED',
63    '-DBOOST_ERROR_CODE_HEADER_ONLY',
64    '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
65]
66
67boost_dep = declare_dependency(
68    dependencies: dependency('boost', required: false),
69    compile_args: boost_compile_args,
70)
71
72sdbusplus_dep = declare_dependency(
73    include_directories: root_inc,
74    link_with: libsdbusplus,
75    dependencies: [boost_dep, libsystemd_pkg, nlohmann_json_dep],
76)
77
78if meson.is_subproject()
79    sdbusplus_dep = sdbusplus_dep.as_system()
80endif
81
82should_generate_cpp = true
83should_generate_markdown = false
84should_generate_registry = false
85
86subdir('tools')
87
88if get_option('examples').allowed()
89    subdir('example')
90endif
91if get_option('tests').allowed()
92    subdir('test')
93endif
94
95install_subdir(
96    'include/sdbusplus',
97    install_dir: get_option('includedir'),
98    strip_directory: false,
99)
100
101import('pkgconfig').generate(
102    libsdbusplus,
103    name: meson.project_name(),
104    version: meson.project_version(),
105    requires: libsystemd_pkg,
106    extra_cflags: boost_compile_args,
107    description: 'C++ bindings for sdbus',
108)
109