blob: 50eaf731338b256a034dda9ea28110e9400657b8 [file] [log] [blame]
Andrew Jefferye984a462024-09-07 11:23:28 +02001project(
2 'libpldm',
3 'c',
Andrew Jeffery9c766792022-08-10 23:12:49 +09304 default_options: [
Andrew Jefferye984a462024-09-07 11:23:28 +02005 'debug=true',
6 'optimization=g',
7 'warning_level=3',
8 'werror=true',
9 'cpp_std=c++23',
10 'c_std=c17',
11 'b_ndebug=if-release',
12 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'),
Andrew Jeffery9c766792022-08-10 23:12:49 +093013 ],
Andrew Jeffery5d8e30c2024-11-01 15:25:54 +103014 version: '0.10.0',
Andrew Jeffery36324f62024-09-25 13:41:41 +093015 meson_version: '>=1.3.0',
Andrew Jeffery9c766792022-08-10 23:12:49 +093016)
17
Andrew Jefferyaa16a0d2024-06-03 16:23:56 +093018if get_option('tests').allowed()
Andrew Jefferye984a462024-09-07 11:23:28 +020019 add_languages('cpp')
Andrew Jefferyaa16a0d2024-06-03 16:23:56 +093020endif
21
Andrew Jeffery2b440d42024-07-25 10:36:08 +093022# For memmem() in src/msgbuf.h
23add_project_arguments('-D_GNU_SOURCE', language: ['c'])
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093024
25compiler = meson.get_compiler('c')
Andrew Jeffery5c49f162024-09-22 15:45:35 +093026if compiler.has_argument('-Wvla')
27 add_project_arguments('-Wvla', language: ['c'])
28endif
29
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093030conf = configuration_data()
31if compiler.has_header('poll.h')
Andrew Jefferye984a462024-09-07 11:23:28 +020032 conf.set('PLDM_HAS_POLL', 1)
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093033endif
34
35# ABI control
Andrew Jeffery36324f62024-09-25 13:41:41 +093036compiler.has_function_attribute('visibility:default', required: true)
37entrypoint = '__attribute__((visibility("default")))'
38
39## Compile test until meson supports it via compiler.has_function_attribute()
40have_tainted_args_test = '#if !__has_attribute(tainted_args)\n#error\n#endif'
41if compiler.compiles(
42 have_tainted_args_test,
43 args: '-E',
44 name: 'compiler supports function attribute tainted_args',
45)
46 entrypoint += ' __attribute__((tainted_args))'
47endif
48
Andrew Jefferyd9b70ba2024-06-08 22:14:49 +093049libpldm_deprecated_aliases = []
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093050if get_option('abi').contains('deprecated')
Andrew Jeffery36324f62024-09-25 13:41:41 +093051 conf.set('LIBPLDM_ABI_DEPRECATED', entrypoint)
52 conf.set(
53 'LIBPLDM_ABI_DEPRECATED_UNSAFE',
54 '__attribute((visibility("default")))',
55 )
Andrew Jefferye984a462024-09-07 11:23:28 +020056 add_project_arguments('-DLIBPLDM_API_DEPRECATED', language: ['c', 'cpp'])
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093057else
Andrew Jefferye984a462024-09-07 11:23:28 +020058 conf.set('LIBPLDM_ABI_DEPRECATED', '')
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093059endif
Andrew Jeffery36324f62024-09-25 13:41:41 +093060conf.set('LIBPLDM_ABI_STABLE', entrypoint) # Always expose the stable symbols
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093061if get_option('abi').contains('testing')
Andrew Jeffery36324f62024-09-25 13:41:41 +093062 conf.set('LIBPLDM_ABI_TESTING', entrypoint)
Andrew Jefferye984a462024-09-07 11:23:28 +020063 add_project_arguments('-DLIBPLDM_API_TESTING', language: ['c', 'cpp'])
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093064else
Andrew Jefferye984a462024-09-07 11:23:28 +020065 conf.set('LIBPLDM_ABI_TESTING', '')
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093066endif
Andrew Jeffery9c766792022-08-10 23:12:49 +093067
Andrew Jefferye984a462024-09-07 11:23:28 +020068config = configure_file(output: 'config.h', configuration: conf)
Andrew Jefferyf89befe2023-06-16 13:02:09 +093069
70add_project_arguments('-include', '@0@'.format(config), language: 'c')
71
Andrew Jefferyb0c1d202023-11-07 22:08:44 +103072libpldm_include_dir = include_directories('include', is_system: true)
Pavithra Barithayaa7989cd2023-10-30 08:52:28 -050073
Andrew Jefferyb0c1d202023-11-07 22:08:44 +103074subdir('include')
Andrew Jefferyb0c1d202023-11-07 22:08:44 +103075subdir('src')
Andrew Jeffery9c766792022-08-10 23:12:49 +093076
Andrew Jefferyd1269362023-11-08 15:54:35 +103077if get_option('tests').allowed()
Andrew Jefferye984a462024-09-07 11:23:28 +020078 subdir('tests')
Andrew Jeffery9c766792022-08-10 23:12:49 +093079endif
Rashmica Gupta6af2a292023-04-27 14:20:17 +100080
Andrew Jefferye984a462024-09-07 11:23:28 +020081install_subdir(
82 'instance-db',
83 install_mode: 'r--r--r--',
84 install_dir: get_option('datadir') / meson.project_name(),
85)