blob: cc58516ae77d76f0cbb4f225e3086a911eef45bb [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 Jefferyd2a36a12023-08-22 10:19:31 +093012 version: '0.6.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 Jeffery9c766792022-08-10 23:12:49 +093046libpldm_sources = files()
47subdir('src')
48
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093049libpldm_include_dir = ['.', 'include', 'src']
Andrew Jeffery9c766792022-08-10 23:12:49 +093050libpldm_headers = files()
Rashmica Guptac1b66f42022-12-09 16:24:45 +110051libpldm_transport_headers = files()
Andrew Jeffery9c766792022-08-10 23:12:49 +093052
53subdir('include/libpldm')
54
55libpldm = library(
56 'pldm',
57 libpldm_sources,
58 implicit_include_directories: false,
59 include_directories: libpldm_include_dir,
60 version: meson.project_version(),
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093061 gnu_symbol_visibility: 'hidden',
Andrew Jeffery9c766792022-08-10 23:12:49 +093062 install: true
63 )
64
65install_headers(
66 libpldm_headers,
67 subdir:'libpldm'
68 )
69
Rashmica Guptac1b66f42022-12-09 16:24:45 +110070install_headers(
71 libpldm_transport_headers,
72 subdir:'libpldm/transport'
73 )
74
Andrew Jeffery9c766792022-08-10 23:12:49 +093075libpldm_dep = declare_dependency(
76 include_directories: libpldm_include_dir,
77 link_with: libpldm)
78
79import('pkgconfig').generate(
80 name: 'libpldm',
81 description: 'PLDM protocol encode/decode C lib',
82 version: meson.project_version(),
83 libraries: libpldm)
84
Andrew Jeffery9c766792022-08-10 23:12:49 +093085if get_option('tests').enabled()
86 subdir('tests')
Andrew Jeffery953bc8c2023-05-22 15:24:17 +093087
Andrew Jeffery33e21a22023-05-29 12:12:36 +093088 c_suite = meson.get_compiler('c').get_id()
89 cpp_suite = meson.get_compiler('cpp').get_id()
90
91 if get_option('abi-compliance-check').allowed() and c_suite == cpp_suite and c_suite == 'gcc'
92 host = host_machine.cpu_family()
93 baseline_dump = meson.project_source_root() / 'abi' / host / '@0@.dump'.format(c_suite)
94
Andrew Jeffery953bc8c2023-05-22 15:24:17 +093095 abi_dumper = find_program('abi-dumper',
96 native: true,
97 required: get_option('abi-compliance-check'))
98 abi_compliance_checker = find_program('abi-compliance-checker',
99 native: true,
100 required: get_option('abi-compliance-check'))
Andrew Jeffery33e21a22023-05-29 12:12:36 +0930101
102 test_abi_compliance = abi_dumper.found() and \
103 abi_compliance_checker.found() and \
104 import('fs').is_file(baseline_dump)
105
Andrew Jeffery4bd6eef2023-06-01 07:25:18 +0930106 if test_abi_compliance
107 current_dump = custom_target('abi-dump',
108 input: libpldm,
109 output: 'current.dump',
110 command: [ abi_dumper,
111 '-public-headers',
112 meson.project_source_root() / 'include',
113 '@INPUT@',
114 '-o',
115 '@OUTPUT@',
116 '-lver',
117 meson.project_version()])
118 abi_compliance = custom_target('abi-compliance',
119 input: [baseline_dump, current_dump],
120 output: 'abi-compliance',
121 command: [ abi_compliance_checker,
122 '-l',
123 meson.project_name(),
124 '-old',
125 '@INPUT0@',
126 '-new',
127 '@INPUT1@' ],
128 build_by_default: true)
129 endif
Andrew Jeffery953bc8c2023-05-22 15:24:17 +0930130 endif
Andrew Jeffery9c766792022-08-10 23:12:49 +0930131endif
Rashmica Gupta6af2a292023-04-27 14:20:17 +1000132
133install_subdir('instance-db',
134 install_mode: 'r--r--r--',
135 install_dir: get_option('datadir') / meson.project_name())