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