xref: /openbmc/sdbusplus/meson.build (revision fc0bb996)
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
24
25root_inc = include_directories('include')
26
27libsdbusplus_src = files(
28    'src/async/context.cpp',
29    'src/async/match.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
74subdir('tools')
75
76if not get_option('examples').disabled()
77  subdir('example')
78endif
79if not get_option('tests').disabled()
80  subdir('test')
81endif
82
83install_subdir(
84    'include/sdbusplus',
85    install_dir: get_option('includedir'),
86    strip_directory: false,
87)
88
89import('pkgconfig').generate(
90    libsdbusplus,
91    name: meson.project_name(),
92    version: meson.project_version(),
93    requires: libsystemd_pkg,
94    extra_cflags: boost_compile_args,
95    description: 'C++ bindings for sdbus',
96)
97