1project( 2 'libpldm', 3 'c', 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', 12 'tests': not meson.is_subproject(), 13 }, 14 version: '0.14.0', 15 meson_version: '>=1.4.0', 16) 17 18if get_option('tests') 19 add_languages('cpp', native: false) 20endif 21 22# For memmem() in src/msgbuf.h 23add_project_arguments('-D_GNU_SOURCE', language: ['c']) 24 25compiler = meson.get_compiler('c') 26if compiler.has_argument('-Wvla') 27 add_project_arguments('-Wvla', language: ['c']) 28endif 29 30conf = configuration_data() 31if compiler.has_header('poll.h') 32 conf.set('PLDM_HAS_POLL', 1) 33endif 34 35# ABI control 36compiler.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 49libpldm_deprecated_aliases = [] 50if get_option('abi').contains('deprecated') 51 conf.set('LIBPLDM_ABI_DEPRECATED', entrypoint) 52 conf.set( 53 'LIBPLDM_ABI_DEPRECATED_UNSAFE', 54 '__attribute__((visibility("default")))', 55 ) 56 add_project_arguments('-DLIBPLDM_API_DEPRECATED', language: ['c', 'cpp']) 57else 58 conf.set('LIBPLDM_ABI_DEPRECATED', '') 59 conf.set('LIBPLDM_ABI_DEPRECATED_UNSAFE', '') 60endif 61conf.set('LIBPLDM_ABI_STABLE', entrypoint) # Always expose the stable symbols 62if get_option('abi').contains('testing') 63 conf.set('LIBPLDM_ABI_TESTING', entrypoint) 64 add_project_arguments('-DLIBPLDM_API_TESTING', language: ['c', 'cpp']) 65else 66 conf.set('LIBPLDM_ABI_TESTING', '') 67endif 68 69config = configure_file(output: 'config.h', configuration: conf) 70 71add_project_arguments('-include', config.full_path(), language: 'c') 72 73libpldm_include_dir = include_directories('include', is_system: true) 74 75subdir('include') 76subdir('src') 77subdir('tools') 78 79doxygen = find_program('doxygen', required: false) 80if doxygen.found() 81 doxydata = configuration_data() 82 doxydata.set('description', meson.project_name()) 83 doxydata.set('project', meson.project_name()) 84 doxydata.set('version', meson.project_version()) 85 doxydata.set( 86 'sources', 87 '@0@ @1@'.format( 88 meson.project_source_root() / 'include', 89 meson.project_source_root() / 'src', 90 ), 91 ) 92 doxyfile = configure_file( 93 input: 'Doxyfile.in', 94 output: 'Doxyfile', 95 configuration: doxydata, 96 install: false, 97 ) 98 99 docs = custom_target( 100 'docs', 101 input: doxyfile, 102 output: 'doxygen', 103 command: [doxygen, doxyfile], 104 ) 105endif 106 107if get_option('tests') 108 subdir('tests') 109endif 110 111install_subdir( 112 'instance-db', 113 install_mode: 'r--r--r--', 114 install_dir: get_option('datadir') / meson.project_name(), 115) 116