Andrew Jeffery | e984a46 | 2024-09-07 11:23:28 +0200 | [diff] [blame] | 1 | project( |
| 2 | 'libpldm', |
| 3 | 'c', |
Andrew Jeffery | a93ec07 | 2024-11-29 11:38:56 +1030 | [diff] [blame] | 4 | default_options: { |
| 5 | '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', |
Andrew Jeffery | 65c6409 | 2024-11-29 11:52:13 +1030 | [diff] [blame] | 12 | 'tests': not meson.is_subproject(), |
Andrew Jeffery | a93ec07 | 2024-11-29 11:38:56 +1030 | [diff] [blame] | 13 | }, |
Andrew Jeffery | 0612d98 | 2024-12-12 11:08:21 +1030 | [diff] [blame] | 14 | version: '0.11.0', |
Andrew Jeffery | 36324f6 | 2024-09-25 13:41:41 +0930 | [diff] [blame] | 15 | meson_version: '>=1.3.0', |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 16 | ) |
| 17 | |
Andrew Jeffery | 65c6409 | 2024-11-29 11:52:13 +1030 | [diff] [blame] | 18 | if get_option('tests') |
Andrew Jeffery | e984a46 | 2024-09-07 11:23:28 +0200 | [diff] [blame] | 19 | add_languages('cpp') |
Andrew Jeffery | aa16a0d | 2024-06-03 16:23:56 +0930 | [diff] [blame] | 20 | endif |
| 21 | |
Andrew Jeffery | 2b440d4 | 2024-07-25 10:36:08 +0930 | [diff] [blame] | 22 | # For memmem() in src/msgbuf.h |
| 23 | add_project_arguments('-D_GNU_SOURCE', language: ['c']) |
Andrew Jeffery | 9d2a1c6 | 2023-06-05 13:02:16 +0930 | [diff] [blame] | 24 | |
| 25 | compiler = meson.get_compiler('c') |
Andrew Jeffery | 5c49f16 | 2024-09-22 15:45:35 +0930 | [diff] [blame] | 26 | if compiler.has_argument('-Wvla') |
| 27 | add_project_arguments('-Wvla', language: ['c']) |
| 28 | endif |
| 29 | |
Andrew Jeffery | 9d2a1c6 | 2023-06-05 13:02:16 +0930 | [diff] [blame] | 30 | conf = configuration_data() |
| 31 | if compiler.has_header('poll.h') |
Andrew Jeffery | e984a46 | 2024-09-07 11:23:28 +0200 | [diff] [blame] | 32 | conf.set('PLDM_HAS_POLL', 1) |
Andrew Jeffery | 9d2a1c6 | 2023-06-05 13:02:16 +0930 | [diff] [blame] | 33 | endif |
| 34 | |
| 35 | # ABI control |
Andrew Jeffery | 36324f6 | 2024-09-25 13:41:41 +0930 | [diff] [blame] | 36 | compiler.has_function_attribute('visibility:default', required: true) |
| 37 | entrypoint = '__attribute__((visibility("default")))' |
| 38 | |
| 39 | ## Compile test until meson supports it via compiler.has_function_attribute() |
| 40 | have_tainted_args_test = '#if !__has_attribute(tainted_args)\n#error\n#endif' |
| 41 | if compiler.compiles( |
| 42 | have_tainted_args_test, |
| 43 | args: '-E', |
| 44 | name: 'compiler supports function attribute tainted_args', |
| 45 | ) |
| 46 | entrypoint += ' __attribute__((tainted_args))' |
| 47 | endif |
| 48 | |
Andrew Jeffery | d9b70ba | 2024-06-08 22:14:49 +0930 | [diff] [blame] | 49 | libpldm_deprecated_aliases = [] |
Andrew Jeffery | 9d2a1c6 | 2023-06-05 13:02:16 +0930 | [diff] [blame] | 50 | if get_option('abi').contains('deprecated') |
Andrew Jeffery | 36324f6 | 2024-09-25 13:41:41 +0930 | [diff] [blame] | 51 | conf.set('LIBPLDM_ABI_DEPRECATED', entrypoint) |
| 52 | conf.set( |
| 53 | 'LIBPLDM_ABI_DEPRECATED_UNSAFE', |
| 54 | '__attribute((visibility("default")))', |
| 55 | ) |
Andrew Jeffery | e984a46 | 2024-09-07 11:23:28 +0200 | [diff] [blame] | 56 | add_project_arguments('-DLIBPLDM_API_DEPRECATED', language: ['c', 'cpp']) |
Andrew Jeffery | 9d2a1c6 | 2023-06-05 13:02:16 +0930 | [diff] [blame] | 57 | else |
Andrew Jeffery | e984a46 | 2024-09-07 11:23:28 +0200 | [diff] [blame] | 58 | conf.set('LIBPLDM_ABI_DEPRECATED', '') |
Andrew Jeffery | 9d2a1c6 | 2023-06-05 13:02:16 +0930 | [diff] [blame] | 59 | endif |
Andrew Jeffery | 36324f6 | 2024-09-25 13:41:41 +0930 | [diff] [blame] | 60 | conf.set('LIBPLDM_ABI_STABLE', entrypoint) # Always expose the stable symbols |
Andrew Jeffery | 9d2a1c6 | 2023-06-05 13:02:16 +0930 | [diff] [blame] | 61 | if get_option('abi').contains('testing') |
Andrew Jeffery | 36324f6 | 2024-09-25 13:41:41 +0930 | [diff] [blame] | 62 | conf.set('LIBPLDM_ABI_TESTING', entrypoint) |
Andrew Jeffery | e984a46 | 2024-09-07 11:23:28 +0200 | [diff] [blame] | 63 | add_project_arguments('-DLIBPLDM_API_TESTING', language: ['c', 'cpp']) |
Andrew Jeffery | 9d2a1c6 | 2023-06-05 13:02:16 +0930 | [diff] [blame] | 64 | else |
Andrew Jeffery | e984a46 | 2024-09-07 11:23:28 +0200 | [diff] [blame] | 65 | conf.set('LIBPLDM_ABI_TESTING', '') |
Andrew Jeffery | 9d2a1c6 | 2023-06-05 13:02:16 +0930 | [diff] [blame] | 66 | endif |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 67 | |
Andrew Jeffery | e984a46 | 2024-09-07 11:23:28 +0200 | [diff] [blame] | 68 | config = configure_file(output: 'config.h', configuration: conf) |
Andrew Jeffery | f89befe | 2023-06-16 13:02:09 +0930 | [diff] [blame] | 69 | |
| 70 | add_project_arguments('-include', '@0@'.format(config), language: 'c') |
| 71 | |
Andrew Jeffery | b0c1d20 | 2023-11-07 22:08:44 +1030 | [diff] [blame] | 72 | libpldm_include_dir = include_directories('include', is_system: true) |
Pavithra Barithaya | a7989cd | 2023-10-30 08:52:28 -0500 | [diff] [blame] | 73 | |
Andrew Jeffery | b0c1d20 | 2023-11-07 22:08:44 +1030 | [diff] [blame] | 74 | subdir('include') |
Andrew Jeffery | b0c1d20 | 2023-11-07 22:08:44 +1030 | [diff] [blame] | 75 | subdir('src') |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 76 | |
Andrew Jeffery | 65c6409 | 2024-11-29 11:52:13 +1030 | [diff] [blame] | 77 | if get_option('tests') |
Andrew Jeffery | e984a46 | 2024-09-07 11:23:28 +0200 | [diff] [blame] | 78 | subdir('tests') |
Andrew Jeffery | 9c76679 | 2022-08-10 23:12:49 +0930 | [diff] [blame] | 79 | endif |
Rashmica Gupta | 6af2a29 | 2023-04-27 14:20:17 +1000 | [diff] [blame] | 80 | |
Andrew Jeffery | e984a46 | 2024-09-07 11:23:28 +0200 | [diff] [blame] | 81 | install_subdir( |
| 82 | 'instance-db', |
| 83 | install_mode: 'r--r--r--', |
| 84 | install_dir: get_option('datadir') / meson.project_name(), |
| 85 | ) |