xref: /openbmc/sdbusplus/meson.build (revision afc8e6e1934ce9e26f9239c634e0e3e1d5772e41)
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')
23stdexec_dep = dependency('stdexec', include_type: 'system')
24
25python = import('python')
26python_bin = python.find_installation(
27    'python3',
28    modules: ['inflection', 'yaml', 'mako'],
29)
30
31if not python_bin.found()
32    error('No valid python3 installation found')
33endif
34
35root_inc = include_directories('include')
36
37libsdbusplus_src = files(
38    'src/async/context.cpp',
39    'src/async/fdio.cpp',
40    'src/async/match.cpp',
41    'src/async/mutex.cpp',
42    'src/bus.cpp',
43    'src/bus/match.cpp',
44    'src/event.cpp',
45    'src/exception.cpp',
46    'src/message/native_types.cpp',
47    'src/sdbus.cpp',
48    'src/server/interface.cpp',
49    'src/server/transaction.cpp',
50)
51
52libsdbusplus = library(
53    'sdbusplus',
54    libsdbusplus_src,
55    include_directories: root_inc,
56    dependencies: [libsystemd_pkg, nlohmann_json_dep, stdexec_dep],
57    version: meson.project_version(),
58    install: true,
59)
60
61boost_compile_args = [
62    '-DBOOST_ASIO_DISABLE_THREADS',
63    '-DBOOST_ALL_NO_LIB',
64    '-DBOOST_SYSTEM_NO_DEPRECATED',
65    '-DBOOST_ERROR_CODE_HEADER_ONLY',
66    '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
67]
68
69boost_dep = declare_dependency(
70    dependencies: dependency('boost', required: false),
71    compile_args: boost_compile_args,
72)
73
74sdbusplus_dep = declare_dependency(
75    include_directories: root_inc,
76    link_with: libsdbusplus,
77    dependencies: [boost_dep, libsystemd_pkg, nlohmann_json_dep, stdexec_dep],
78)
79
80if meson.is_subproject()
81    sdbusplus_dep = sdbusplus_dep.as_system()
82endif
83
84should_generate_cpp = true
85should_generate_markdown = false
86should_generate_registry = false
87
88subdir('tools')
89
90if get_option('examples').allowed()
91    subdir('example')
92endif
93if get_option('tests').allowed()
94    subdir('test')
95endif
96
97install_subdir(
98    'include/sdbusplus',
99    install_dir: get_option('includedir'),
100    strip_directory: false,
101)
102
103import('pkgconfig').generate(
104    libsdbusplus,
105    name: meson.project_name(),
106    version: meson.project_version(),
107    requires: libsystemd_pkg,
108    extra_cflags: boost_compile_args,
109    description: 'C++ bindings for sdbus',
110)
111