xref: /openbmc/libpldm/meson.build (revision 1c4c704d)
1project(
2    'libpldm',
3    'c',
4    default_options: [
5        'debug=true',
6        'optimization=g',
7        'warning_level=3',
8        'werror=true',
9        'cpp_std=c++23',
10        'c_std=c17',
11        'b_ndebug=if-release',
12        'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'),
13    ],
14    version: '0.9.1',
15    meson_version: '>=1.1.1',
16)
17
18if get_option('tests').allowed()
19    add_languages('cpp')
20endif
21
22# For memmem() in src/msgbuf.h
23add_project_arguments('-D_GNU_SOURCE', language: ['c'])
24
25compiler = meson.get_compiler('c')
26if compiler.has_argument('-Wvla')
27    add_project_arguments('-Wvla', language: ['c'])
28endif
29
30conf = configuration_data()
31if compiler.has_header('poll.h')
32    conf.set('PLDM_HAS_POLL', 1)
33endif
34
35# ABI control
36visible = '__attribute__((visibility("default")))'
37libpldm_deprecated_aliases = []
38if get_option('abi').contains('deprecated')
39    conf.set('LIBPLDM_ABI_DEPRECATED', visible)
40    add_project_arguments('-DLIBPLDM_API_DEPRECATED', language: ['c', 'cpp'])
41else
42    conf.set('LIBPLDM_ABI_DEPRECATED', '')
43endif
44conf.set('LIBPLDM_ABI_STABLE', visible)  # Always expose the stable symbols
45if get_option('abi').contains('testing')
46    conf.set('LIBPLDM_ABI_TESTING', visible)
47    add_project_arguments('-DLIBPLDM_API_TESTING', language: ['c', 'cpp'])
48else
49    conf.set('LIBPLDM_ABI_TESTING', '')
50endif
51
52config = configure_file(output: 'config.h', configuration: conf)
53
54add_project_arguments('-include', '@0@'.format(config), language: 'c')
55
56libpldm_include_dir = include_directories('include', is_system: true)
57
58subdir('include')
59subdir('src')
60
61if get_option('tests').allowed()
62    subdir('tests')
63endif
64
65install_subdir(
66    'instance-db',
67    install_mode: 'r--r--r--',
68    install_dir: get_option('datadir') / meson.project_name(),
69)
70