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.12.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 = [ 50 ['crc32', 'pldm_edac_crc32'], 51 ['crc8', 'pldm_edac_crc8'], 52] 53if get_option('abi').contains('deprecated') 54 conf.set('LIBPLDM_ABI_DEPRECATED', entrypoint) 55 conf.set( 56 'LIBPLDM_ABI_DEPRECATED_UNSAFE', 57 '__attribute((visibility("default")))', 58 ) 59 add_project_arguments('-DLIBPLDM_API_DEPRECATED', language: ['c', 'cpp']) 60else 61 conf.set('LIBPLDM_ABI_DEPRECATED', '') 62endif 63conf.set('LIBPLDM_ABI_STABLE', entrypoint) # Always expose the stable symbols 64if get_option('abi').contains('testing') 65 conf.set('LIBPLDM_ABI_TESTING', entrypoint) 66 add_project_arguments('-DLIBPLDM_API_TESTING', language: ['c', 'cpp']) 67else 68 conf.set('LIBPLDM_ABI_TESTING', '') 69endif 70 71config = configure_file(output: 'config.h', configuration: conf) 72 73add_project_arguments('-include', config.full_path(), language: 'c') 74 75libpldm_include_dir = include_directories('include', is_system: true) 76 77subdir('include') 78subdir('src') 79 80doxygen = find_program('doxygen', required: false) 81if doxygen.found() 82 doxydata = configuration_data() 83 doxydata.set('description', meson.project_name()) 84 doxydata.set('project', meson.project_name()) 85 doxydata.set('version', meson.project_version()) 86 doxydata.set( 87 'sources', 88 '@0@ @1@'.format( 89 meson.project_source_root() / 'include', 90 meson.project_source_root() / 'src', 91 ), 92 ) 93 doxyfile = configure_file( 94 input: 'Doxyfile.in', 95 output: 'Doxyfile', 96 configuration: doxydata, 97 install: false, 98 ) 99 100 docs = custom_target( 101 'docs', 102 input: doxyfile, 103 output: 'doxygen', 104 command: [doxygen, doxyfile], 105 ) 106endif 107 108if get_option('tests') 109 subdir('tests') 110endif 111 112install_subdir( 113 'instance-db', 114 install_mode: 'r--r--r--', 115 install_dir: get_option('datadir') / meson.project_name(), 116) 117