blob: 86b22509ecac6b17b428ed35bdfdb6d472351b0c [file] [log] [blame]
Andrew Jeffery9c766792022-08-10 23:12:49 +09301project('libpldm', ['c','cpp'],
2 default_options: [
Andrew Jeffery953bc8c2023-05-22 15:24:17 +09303 'debug=true',
4 'optimization=g',
Andrew Jeffery9c766792022-08-10 23:12:49 +09305 'warning_level=3',
6 'werror=true',
7 'cpp_std=c++20',
8 'c_std=c17',
Andrew Jeffery5cf32ea2023-07-03 13:40:00 +09309 'b_ndebug=if-release',
Andrew Jeffery9c766792022-08-10 23:12:49 +093010 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'),
11 ],
Andrew Jeffery3f39f962023-08-29 14:54:29 +093012 version: '0.7.0',
George Liubfd06e42023-08-16 10:30:13 +080013 meson_version: '>=1.1.0',
Andrew Jeffery9c766792022-08-10 23:12:49 +093014)
15
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093016add_project_arguments('-D_DEFAULT_SOURCE', language: ['c'])
17
18compiler = meson.get_compiler('c')
19conf = configuration_data()
20if compiler.has_header('poll.h')
21 conf.set('PLDM_HAS_POLL', 1)
22endif
23
24# ABI control
25visible = '__attribute__((visibility("default")))'
26if get_option('abi').contains('deprecated')
27 conf.set('LIBPLDM_ABI_DEPRECATED', visible)
28 add_project_arguments('-DLIBPLDM_API_DEPRECATED', language: ['c', 'cpp'])
29else
30 conf.set('LIBPLDM_ABI_DEPRECATED', '')
31endif
32conf.set('LIBPLDM_ABI_STABLE', visible) # Always expose the stable symbols
33if get_option('abi').contains('testing')
34 conf.set('LIBPLDM_ABI_TESTING', visible)
35 add_project_arguments('-DLIBPLDM_API_TESTING', language: ['c', 'cpp'])
36else
37 conf.set('LIBPLDM_ABI_TESTING', '')
38endif
Andrew Jeffery9c766792022-08-10 23:12:49 +093039
Andrew Jefferyf89befe2023-06-16 13:02:09 +093040config = configure_file(output: 'config.h',
41 configuration: conf
42)
43
44add_project_arguments('-include', '@0@'.format(config), language: 'c')
45
Andrew Jefferyb0c1d202023-11-07 22:08:44 +103046libpldm_include_dir = include_directories('include', is_system: true)
Pavithra Barithayaa7989cd2023-10-30 08:52:28 -050047
Andrew Jefferyb0c1d202023-11-07 22:08:44 +103048subdir('include')
Andrew Jefferyb0c1d202023-11-07 22:08:44 +103049subdir('src')
Andrew Jeffery9c766792022-08-10 23:12:49 +093050
Andrew Jeffery9c766792022-08-10 23:12:49 +093051if get_option('tests').enabled()
52 subdir('tests')
Andrew Jeffery953bc8c2023-05-22 15:24:17 +093053
Andrew Jeffery33e21a22023-05-29 12:12:36 +093054 c_suite = meson.get_compiler('c').get_id()
55 cpp_suite = meson.get_compiler('cpp').get_id()
56
57 if get_option('abi-compliance-check').allowed() and c_suite == cpp_suite and c_suite == 'gcc'
58 host = host_machine.cpu_family()
59 baseline_dump = meson.project_source_root() / 'abi' / host / '@0@.dump'.format(c_suite)
60
Andrew Jeffery953bc8c2023-05-22 15:24:17 +093061 abi_dumper = find_program('abi-dumper',
62 native: true,
63 required: get_option('abi-compliance-check'))
64 abi_compliance_checker = find_program('abi-compliance-checker',
65 native: true,
66 required: get_option('abi-compliance-check'))
Andrew Jeffery33e21a22023-05-29 12:12:36 +093067
68 test_abi_compliance = abi_dumper.found() and \
69 abi_compliance_checker.found() and \
70 import('fs').is_file(baseline_dump)
71
Andrew Jeffery4bd6eef2023-06-01 07:25:18 +093072 if test_abi_compliance
73 current_dump = custom_target('abi-dump',
74 input: libpldm,
75 output: 'current.dump',
76 command: [ abi_dumper,
77 '-public-headers',
78 meson.project_source_root() / 'include',
79 '@INPUT@',
80 '-o',
81 '@OUTPUT@',
82 '-lver',
83 meson.project_version()])
84 abi_compliance = custom_target('abi-compliance',
85 input: [baseline_dump, current_dump],
86 output: 'abi-compliance',
87 command: [ abi_compliance_checker,
88 '-l',
89 meson.project_name(),
90 '-old',
91 '@INPUT0@',
92 '-new',
93 '@INPUT1@' ],
94 build_by_default: true)
95 endif
Andrew Jeffery953bc8c2023-05-22 15:24:17 +093096 endif
Andrew Jeffery9c766792022-08-10 23:12:49 +093097endif
Rashmica Gupta6af2a292023-04-27 14:20:17 +100098
99install_subdir('instance-db',
100 install_mode: 'r--r--r--',
101 install_dir: get_option('datadir') / meson.project_name())