blob: 9bb4f5a7f48be84c83ede0676e8cb031db1cce2e [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
67 if get_option('abi-compliance-check').allowed()
68 abi_dumper = find_program('abi-dumper',
69 native: true,
70 required: get_option('abi-compliance-check'))
71 abi_compliance_checker = find_program('abi-compliance-checker',
72 native: true,
73 required: get_option('abi-compliance-check'))
74 public_api_dir = meson.project_source_root() / 'include'
75 baseline_dump = meson.project_source_root() / 'abi' / 'baseline.dump'
76 current_dump = custom_target('abi-dump',
77 input: libpldm,
78 output: 'current.dump',
79 command: [ abi_dumper,
80 '-public-headers',
81 public_api_dir,
82 '@INPUT@',
83 '-o',
84 '@OUTPUT@',
85 '-lver',
86 meson.project_version()])
87 test_abi_compliance = abi_dumper.found() and \
88 abi_compliance_checker.found() and \
89 meson.get_compiler('c').get_id() == 'gcc' and \
90 meson.get_compiler('cpp').get_id() == 'gcc'
91 abi_compliance = custom_target('abi-compliance',
92 input: [baseline_dump, current_dump],
93 output: 'abi-compliance',
94 command: [ abi_compliance_checker,
95 '-l',
96 meson.project_name(),
97 '-old',
98 '@INPUT0@',
99 '-new',
100 '@INPUT1@' ],
101 build_by_default: test_abi_compliance)
102 endif
Andrew Jeffery9c766792022-08-10 23:12:49 +0930103endif
Rashmica Gupta6af2a292023-04-27 14:20:17 +1000104
105install_subdir('instance-db',
106 install_mode: 'r--r--r--',
107 install_dir: get_option('datadir') / meson.project_name())