blob: 0f8fa918d8b8533b59015127614c7fb0ce485d53 [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 Jefferya2ce1362023-02-13 15:26:29 +103011 version: '0.2.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
39libpldm_sources = files()
40subdir('src')
41
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093042libpldm_include_dir = ['.', 'include', 'src']
Andrew Jeffery9c766792022-08-10 23:12:49 +093043libpldm_headers = files()
Rashmica Guptac1b66f42022-12-09 16:24:45 +110044libpldm_transport_headers = files()
Andrew Jeffery9c766792022-08-10 23:12:49 +093045
46subdir('include/libpldm')
47
48libpldm = library(
49 'pldm',
50 libpldm_sources,
51 implicit_include_directories: false,
52 include_directories: libpldm_include_dir,
53 version: meson.project_version(),
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093054 gnu_symbol_visibility: 'hidden',
Andrew Jeffery9c766792022-08-10 23:12:49 +093055 install: true
56 )
57
58install_headers(
59 libpldm_headers,
60 subdir:'libpldm'
61 )
62
Rashmica Guptac1b66f42022-12-09 16:24:45 +110063install_headers(
64 libpldm_transport_headers,
65 subdir:'libpldm/transport'
66 )
67
Andrew Jeffery9c766792022-08-10 23:12:49 +093068libpldm_dep = declare_dependency(
69 include_directories: libpldm_include_dir,
70 link_with: libpldm)
71
72import('pkgconfig').generate(
73 name: 'libpldm',
74 description: 'PLDM protocol encode/decode C lib',
75 version: meson.project_version(),
76 libraries: libpldm)
77
Rashmica Guptac1b66f42022-12-09 16:24:45 +110078configure_file(output: 'config.h',
79 configuration: conf
80)
81
Andrew Jeffery9c766792022-08-10 23:12:49 +093082if get_option('tests').enabled()
83 subdir('tests')
Andrew Jeffery953bc8c2023-05-22 15:24:17 +093084
Andrew Jeffery33e21a22023-05-29 12:12:36 +093085 c_suite = meson.get_compiler('c').get_id()
86 cpp_suite = meson.get_compiler('cpp').get_id()
87
88 if get_option('abi-compliance-check').allowed() and c_suite == cpp_suite and c_suite == 'gcc'
89 host = host_machine.cpu_family()
90 baseline_dump = meson.project_source_root() / 'abi' / host / '@0@.dump'.format(c_suite)
91
Andrew Jeffery953bc8c2023-05-22 15:24:17 +093092 abi_dumper = find_program('abi-dumper',
93 native: true,
94 required: get_option('abi-compliance-check'))
95 abi_compliance_checker = find_program('abi-compliance-checker',
96 native: true,
97 required: get_option('abi-compliance-check'))
Andrew Jeffery33e21a22023-05-29 12:12:36 +093098
99 test_abi_compliance = abi_dumper.found() and \
100 abi_compliance_checker.found() and \
101 import('fs').is_file(baseline_dump)
102
Andrew Jeffery4bd6eef2023-06-01 07:25:18 +0930103 if test_abi_compliance
104 current_dump = custom_target('abi-dump',
105 input: libpldm,
106 output: 'current.dump',
107 command: [ abi_dumper,
108 '-public-headers',
109 meson.project_source_root() / 'include',
110 '@INPUT@',
111 '-o',
112 '@OUTPUT@',
113 '-lver',
114 meson.project_version()])
115 abi_compliance = custom_target('abi-compliance',
116 input: [baseline_dump, current_dump],
117 output: 'abi-compliance',
118 command: [ abi_compliance_checker,
119 '-l',
120 meson.project_name(),
121 '-old',
122 '@INPUT0@',
123 '-new',
124 '@INPUT1@' ],
125 build_by_default: true)
126 endif
Andrew Jeffery953bc8c2023-05-22 15:24:17 +0930127 endif
Andrew Jeffery9c766792022-08-10 23:12:49 +0930128endif
Rashmica Gupta6af2a292023-04-27 14:20:17 +1000129
130install_subdir('instance-db',
131 install_mode: 'r--r--r--',
132 install_dir: get_option('datadir') / meson.project_name())