xref: /openbmc/sdbusplus/meson.build (revision bd04c3b26ec121fdcf9715f2173ca986a01ab2e3)
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/async/mutex.cpp',
41    'src/bus.cpp',
42    'src/bus/match.cpp',
43    'src/event.cpp',
44    'src/exception.cpp',
45    'src/message/native_types.cpp',
46    'src/sdbus.cpp',
47    'src/server/interface.cpp',
48    'src/server/transaction.cpp',
49)
50
51libsdbusplus = library(
52    'sdbusplus',
53    libsdbusplus_src,
54    include_directories: root_inc,
55    dependencies: [libsystemd_pkg, nlohmann_json_dep],
56    version: meson.project_version(),
57    install: true,
58)
59
60boost_compile_args = [
61    '-DBOOST_ASIO_DISABLE_THREADS',
62    '-DBOOST_ALL_NO_LIB',
63    '-DBOOST_SYSTEM_NO_DEPRECATED',
64    '-DBOOST_ERROR_CODE_HEADER_ONLY',
65    '-DBOOST_COROUTINES_NO_DEPRECATION_WARNING',
66]
67
68boost_dep = declare_dependency(
69    dependencies: dependency('boost', required: false),
70    compile_args: boost_compile_args,
71)
72
73sdbusplus_dep = declare_dependency(
74    include_directories: root_inc,
75    link_with: libsdbusplus,
76    dependencies: [boost_dep, libsystemd_pkg, nlohmann_json_dep],
77)
78
79if meson.is_subproject()
80    sdbusplus_dep = sdbusplus_dep.as_system()
81endif
82
83should_generate_cpp = true
84should_generate_markdown = false
85should_generate_registry = false
86
87subdir('tools')
88
89if get_option('examples').allowed()
90    subdir('example')
91endif
92if get_option('tests').allowed()
93    subdir('test')
94endif
95
96install_subdir(
97    'include/sdbusplus',
98    install_dir: get_option('includedir'),
99    strip_directory: false,
100)
101
102import('pkgconfig').generate(
103    libsdbusplus,
104    name: meson.project_name(),
105    version: meson.project_version(),
106    requires: libsystemd_pkg,
107    extra_cflags: boost_compile_args,
108    description: 'C++ bindings for sdbus',
109)
110