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