xref: /openbmc/libpldm/meson.build (revision 73a2f66e)
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')
26conf = configuration_data()
27if compiler.has_header('poll.h')
28    conf.set('PLDM_HAS_POLL', 1)
29endif
30
31# ABI control
32visible = '__attribute__((visibility("default")))'
33libpldm_deprecated_aliases = []
34if get_option('abi').contains('deprecated')
35    conf.set('LIBPLDM_ABI_DEPRECATED', visible)
36    add_project_arguments('-DLIBPLDM_API_DEPRECATED', language: ['c', 'cpp'])
37    libpldm_deprecated_aliases += [
38        ['get_fru_record_by_option_check', 'get_fru_record_by_option'],
39        ['pldm_pdr_add_check', 'pldm_pdr_add'],
40        ['pldm_pdr_add_fru_record_set_check', 'pldm_pdr_add_fru_record_set'],
41    ]
42else
43    conf.set('LIBPLDM_ABI_DEPRECATED', '')
44endif
45conf.set('LIBPLDM_ABI_STABLE', visible)  # Always expose the stable symbols
46if get_option('abi').contains('testing')
47    conf.set('LIBPLDM_ABI_TESTING', visible)
48    add_project_arguments('-DLIBPLDM_API_TESTING', language: ['c', 'cpp'])
49else
50    conf.set('LIBPLDM_ABI_TESTING', '')
51endif
52
53config = configure_file(output: 'config.h', configuration: conf)
54
55add_project_arguments('-include', '@0@'.format(config), language: 'c')
56
57libpldm_include_dir = include_directories('include', is_system: true)
58
59subdir('include')
60subdir('src')
61
62if get_option('tests').allowed()
63    subdir('tests')
64endif
65
66install_subdir(
67    'instance-db',
68    install_mode: 'r--r--r--',
69    install_dir: get_option('datadir') / meson.project_name(),
70)
71