blob: da594cb40e4a123666c1affb2a4e656d0e805e6a [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',
9 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'),
10 ],
Andrew Jeffery20cc0602023-08-09 15:16:44 +093011 version: '0.5.0',
Andrew Jeffery9c766792022-08-10 23:12:49 +093012 meson_version: '>=0.63.0',
13)
14
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093015add_project_arguments('-D_DEFAULT_SOURCE', language: ['c'])
16
17compiler = meson.get_compiler('c')
18conf = configuration_data()
19if compiler.has_header('poll.h')
20 conf.set('PLDM_HAS_POLL', 1)
21endif
22
23# ABI control
24visible = '__attribute__((visibility("default")))'
25if get_option('abi').contains('deprecated')
26 conf.set('LIBPLDM_ABI_DEPRECATED', visible)
27 add_project_arguments('-DLIBPLDM_API_DEPRECATED', language: ['c', 'cpp'])
28else
29 conf.set('LIBPLDM_ABI_DEPRECATED', '')
30endif
31conf.set('LIBPLDM_ABI_STABLE', visible) # Always expose the stable symbols
32if get_option('abi').contains('testing')
33 conf.set('LIBPLDM_ABI_TESTING', visible)
34 add_project_arguments('-DLIBPLDM_API_TESTING', language: ['c', 'cpp'])
35else
36 conf.set('LIBPLDM_ABI_TESTING', '')
37endif
Andrew Jeffery9c766792022-08-10 23:12:49 +093038
Andrew Jefferyf89befe2023-06-16 13:02:09 +093039config = configure_file(output: 'config.h',
40 configuration: conf
41)
42
43add_project_arguments('-include', '@0@'.format(config), language: 'c')
44
Andrew Jeffery9c766792022-08-10 23:12:49 +093045libpldm_sources = files()
46subdir('src')
47
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093048libpldm_include_dir = ['.', 'include', 'src']
Andrew Jeffery9c766792022-08-10 23:12:49 +093049libpldm_headers = files()
Rashmica Guptac1b66f42022-12-09 16:24:45 +110050libpldm_transport_headers = files()
Andrew Jeffery9c766792022-08-10 23:12:49 +093051
52subdir('include/libpldm')
53
54libpldm = library(
55 'pldm',
56 libpldm_sources,
57 implicit_include_directories: false,
58 include_directories: libpldm_include_dir,
59 version: meson.project_version(),
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093060 gnu_symbol_visibility: 'hidden',
Andrew Jeffery9c766792022-08-10 23:12:49 +093061 install: true
62 )
63
64install_headers(
65 libpldm_headers,
66 subdir:'libpldm'
67 )
68
Rashmica Guptac1b66f42022-12-09 16:24:45 +110069install_headers(
70 libpldm_transport_headers,
71 subdir:'libpldm/transport'
72 )
73
Andrew Jeffery9c766792022-08-10 23:12:49 +093074libpldm_dep = declare_dependency(
75 include_directories: libpldm_include_dir,
76 link_with: libpldm)
77
78import('pkgconfig').generate(
79 name: 'libpldm',
80 description: 'PLDM protocol encode/decode C lib',
81 version: meson.project_version(),
82 libraries: libpldm)
83
Andrew Jeffery9c766792022-08-10 23:12:49 +093084if get_option('tests').enabled()
85 subdir('tests')
Andrew Jeffery953bc8c2023-05-22 15:24:17 +093086
Andrew Jeffery33e21a22023-05-29 12:12:36 +093087 c_suite = meson.get_compiler('c').get_id()
88 cpp_suite = meson.get_compiler('cpp').get_id()
89
90 if get_option('abi-compliance-check').allowed() and c_suite == cpp_suite and c_suite == 'gcc'
91 host = host_machine.cpu_family()
92 baseline_dump = meson.project_source_root() / 'abi' / host / '@0@.dump'.format(c_suite)
93
Andrew Jeffery953bc8c2023-05-22 15:24:17 +093094 abi_dumper = find_program('abi-dumper',
95 native: true,
96 required: get_option('abi-compliance-check'))
97 abi_compliance_checker = find_program('abi-compliance-checker',
98 native: true,
99 required: get_option('abi-compliance-check'))
Andrew Jeffery33e21a22023-05-29 12:12:36 +0930100
101 test_abi_compliance = abi_dumper.found() and \
102 abi_compliance_checker.found() and \
103 import('fs').is_file(baseline_dump)
104
Andrew Jeffery4bd6eef2023-06-01 07:25:18 +0930105 if test_abi_compliance
106 current_dump = custom_target('abi-dump',
107 input: libpldm,
108 output: 'current.dump',
109 command: [ abi_dumper,
110 '-public-headers',
111 meson.project_source_root() / 'include',
112 '@INPUT@',
113 '-o',
114 '@OUTPUT@',
115 '-lver',
116 meson.project_version()])
117 abi_compliance = custom_target('abi-compliance',
118 input: [baseline_dump, current_dump],
119 output: 'abi-compliance',
120 command: [ abi_compliance_checker,
121 '-l',
122 meson.project_name(),
123 '-old',
124 '@INPUT0@',
125 '-new',
126 '@INPUT1@' ],
127 build_by_default: true)
128 endif
Andrew Jeffery953bc8c2023-05-22 15:24:17 +0930129 endif
Andrew Jeffery9c766792022-08-10 23:12:49 +0930130endif
Rashmica Gupta6af2a292023-04-27 14:20:17 +1000131
132install_subdir('instance-db',
133 install_mode: 'r--r--r--',
134 install_dir: get_option('datadir') / meson.project_name())