blob: 80d0c93f55ebbecde9c60697640c84ff7623f813 [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
15add_project_arguments('-D_DEFAULT_SOURCE',language:['c'])
16
17libpldm_sources = files()
18subdir('src')
19
Andrew Jefferyc63f63a2023-02-24 22:29:33 +103020libpldm_include_dir = ['include', 'src']
Andrew Jeffery9c766792022-08-10 23:12:49 +093021libpldm_headers = files()
Rashmica Guptac1b66f42022-12-09 16:24:45 +110022libpldm_transport_headers = files()
Andrew Jeffery9c766792022-08-10 23:12:49 +093023
24subdir('include/libpldm')
25
26libpldm = library(
27 'pldm',
28 libpldm_sources,
29 implicit_include_directories: false,
30 include_directories: libpldm_include_dir,
31 version: meson.project_version(),
32 install: true
33 )
34
35install_headers(
36 libpldm_headers,
37 subdir:'libpldm'
38 )
39
Rashmica Guptac1b66f42022-12-09 16:24:45 +110040install_headers(
41 libpldm_transport_headers,
42 subdir:'libpldm/transport'
43 )
44
Andrew Jeffery9c766792022-08-10 23:12:49 +093045libpldm_dep = declare_dependency(
46 include_directories: libpldm_include_dir,
47 link_with: libpldm)
48
49import('pkgconfig').generate(
50 name: 'libpldm',
51 description: 'PLDM protocol encode/decode C lib',
52 version: meson.project_version(),
53 libraries: libpldm)
54
Rashmica Guptac1b66f42022-12-09 16:24:45 +110055compiler = meson.get_compiler('c')
56conf = configuration_data()
57if compiler.has_header('poll.h')
58 conf.set('PLDM_HAS_POLL', 1)
59endif
60configure_file(output: 'config.h',
61 configuration: conf
62)
63
Andrew Jeffery9c766792022-08-10 23:12:49 +093064if get_option('tests').enabled()
65 subdir('tests')
Andrew Jeffery953bc8c2023-05-22 15:24:17 +093066
Andrew Jeffery33e21a22023-05-29 12:12:36 +093067 c_suite = meson.get_compiler('c').get_id()
68 cpp_suite = meson.get_compiler('cpp').get_id()
69
70 if get_option('abi-compliance-check').allowed() and c_suite == cpp_suite and c_suite == 'gcc'
71 host = host_machine.cpu_family()
72 baseline_dump = meson.project_source_root() / 'abi' / host / '@0@.dump'.format(c_suite)
73
Andrew Jeffery953bc8c2023-05-22 15:24:17 +093074 abi_dumper = find_program('abi-dumper',
75 native: true,
76 required: get_option('abi-compliance-check'))
77 abi_compliance_checker = find_program('abi-compliance-checker',
78 native: true,
79 required: get_option('abi-compliance-check'))
Andrew Jeffery33e21a22023-05-29 12:12:36 +093080
81 test_abi_compliance = abi_dumper.found() and \
82 abi_compliance_checker.found() and \
83 import('fs').is_file(baseline_dump)
84
Andrew Jeffery4bd6eef2023-06-01 07:25:18 +093085 if test_abi_compliance
86 current_dump = custom_target('abi-dump',
87 input: libpldm,
88 output: 'current.dump',
89 command: [ abi_dumper,
90 '-public-headers',
91 meson.project_source_root() / 'include',
92 '@INPUT@',
93 '-o',
94 '@OUTPUT@',
95 '-lver',
96 meson.project_version()])
97 abi_compliance = custom_target('abi-compliance',
98 input: [baseline_dump, current_dump],
99 output: 'abi-compliance',
100 command: [ abi_compliance_checker,
101 '-l',
102 meson.project_name(),
103 '-old',
104 '@INPUT0@',
105 '-new',
106 '@INPUT1@' ],
107 build_by_default: true)
108 endif
Andrew Jeffery953bc8c2023-05-22 15:24:17 +0930109 endif
Andrew Jeffery9c766792022-08-10 23:12:49 +0930110endif
Rashmica Gupta6af2a292023-04-27 14:20:17 +1000111
112install_subdir('instance-db',
113 install_mode: 'r--r--r--',
114 install_dir: get_option('datadir') / meson.project_name())