blob: 560effb14c4bd35952351038be5958e7690d863d [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 Jeffery615344f2024-09-07 11:58:37 +020014 version: '0.9.1',
Patrick Williamsa9db43f2023-08-23 06:31:22 -050015 meson_version: '>=1.1.1',
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 Jefferye984a462024-09-07 11:23:28 +020036visible = '__attribute__((visibility("default")))'
Andrew Jefferyd9b70ba2024-06-08 22:14:49 +093037libpldm_deprecated_aliases = []
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093038if get_option('abi').contains('deprecated')
Andrew Jefferye984a462024-09-07 11:23:28 +020039 conf.set('LIBPLDM_ABI_DEPRECATED', visible)
40 add_project_arguments('-DLIBPLDM_API_DEPRECATED', language: ['c', 'cpp'])
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093041else
Andrew Jefferye984a462024-09-07 11:23:28 +020042 conf.set('LIBPLDM_ABI_DEPRECATED', '')
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093043endif
Andrew Jefferye984a462024-09-07 11:23:28 +020044conf.set('LIBPLDM_ABI_STABLE', visible) # Always expose the stable symbols
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093045if get_option('abi').contains('testing')
Andrew Jefferye984a462024-09-07 11:23:28 +020046 conf.set('LIBPLDM_ABI_TESTING', visible)
47 add_project_arguments('-DLIBPLDM_API_TESTING', language: ['c', 'cpp'])
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093048else
Andrew Jefferye984a462024-09-07 11:23:28 +020049 conf.set('LIBPLDM_ABI_TESTING', '')
Andrew Jeffery9d2a1c62023-06-05 13:02:16 +093050endif
Andrew Jeffery9c766792022-08-10 23:12:49 +093051
Andrew Jefferye984a462024-09-07 11:23:28 +020052config = configure_file(output: 'config.h', configuration: conf)
Andrew Jefferyf89befe2023-06-16 13:02:09 +093053
54add_project_arguments('-include', '@0@'.format(config), language: 'c')
55
Andrew Jefferyb0c1d202023-11-07 22:08:44 +103056libpldm_include_dir = include_directories('include', is_system: true)
Pavithra Barithayaa7989cd2023-10-30 08:52:28 -050057
Andrew Jefferyb0c1d202023-11-07 22:08:44 +103058subdir('include')
Andrew Jefferyb0c1d202023-11-07 22:08:44 +103059subdir('src')
Andrew Jeffery9c766792022-08-10 23:12:49 +093060
Andrew Jefferyd1269362023-11-08 15:54:35 +103061if get_option('tests').allowed()
Andrew Jefferye984a462024-09-07 11:23:28 +020062 subdir('tests')
Andrew Jeffery9c766792022-08-10 23:12:49 +093063endif
Rashmica Gupta6af2a292023-04-27 14:20:17 +100064
Andrew Jefferye984a462024-09-07 11:23:28 +020065install_subdir(
66 'instance-db',
67 install_mode: 'r--r--r--',
68 install_dir: get_option('datadir') / meson.project_name(),
69)