1project( 2 'phosphor-snmp', 'cpp', 3 version : '1.0.0', 4 meson_version: '>=1.1.1', 5 default_options: [ 6 'warning_level=3', 7 'werror=true', 8 'cpp_std=c++23', 9 'buildtype=debugoptimized', 10 ] 11) 12 13conf_data = configuration_data() 14conf_data.set_quoted('BUSNAME_NETWORK_SNMP', 'xyz.openbmc_project.Network.SNMP') 15conf_data.set_quoted('OBJ_NETWORK_SNMP', '/xyz/openbmc_project/network/snmp/manager') 16conf_data.set_quoted('SNMP_CONF_PERSIST_PATH', '/var/lib/phosphor-snmp/managers/') 17conf_data.set('CLASS_VERSION', 1) 18 19sdbusplus_dep = dependency('sdbusplus') 20phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 21phosphor_logging_dep = dependency('phosphor-logging') 22libsystemd_dep = dependency('libsystemd') 23netsnmp_dep = dependency('netsnmp') 24libcrypto_dep = dependency('libcrypto') 25 26cpp = meson.get_compiler('cpp') 27 28# Get Cereal dependency. 29cereal_dep = dependency('cereal', required: false) 30has_cereal = cpp.has_header_symbol( 31 'cereal/cereal.hpp', 32 'cereal::specialize', 33 dependencies: cereal_dep, 34 required: false) 35if not has_cereal 36 cereal_opts = import('cmake').subproject_options() 37 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'}) 38 cereal_proj = import('cmake').subproject( 39 'cereal', 40 options: cereal_opts, 41 required: false) 42 assert(cereal_proj.found(), 'cereal is required') 43 cereal_dep = cereal_proj.dependency('cereal') 44endif 45 46snmp_headers = include_directories('.') 47 48deps = [ 49 libsystemd_dep, 50 phosphor_dbus_interfaces_dep, 51 phosphor_logging_dep, 52 sdbusplus_dep, 53 cereal_dep, 54] 55 56sources = [ 57 'snmp_main.cpp', 58 'snmp_conf_manager.cpp', 59 'snmp_client.cpp', 60 'snmp_util.cpp', 61 'snmp_serialize.cpp', 62] 63 64configure_file(output: 'config.h', 65 configuration: conf_data 66) 67 68executable( 69 'phosphor-network-snmpconf', 70 sources, 71 implicit_include_directories: true, 72 dependencies: deps, 73 install: true, 74 install_dir: get_option('bindir') 75) 76 77libsnmp_deps = [ 78 sdbusplus_dep, 79 phosphor_logging_dep, 80 phosphor_dbus_interfaces_dep, 81 netsnmp_dep, 82 libcrypto_dep, 83] 84 85libsnmp_sources = files( 86 'snmp_notification.cpp', 87 'snmp_util.cpp', 88) 89 90libsnmp_lib = library( 91 'snmp', 92 libsnmp_sources, 93 include_directories: snmp_headers, 94 implicit_include_directories: false, 95 dependencies: libsnmp_deps, 96 version: meson.project_version(), 97 install: true, 98) 99 100phosphor_snmp_dep = declare_dependency( 101 include_directories: snmp_headers, 102 link_with: libsnmp_lib, 103) 104 105import('pkgconfig').generate( 106 libsnmp_lib, 107 name: meson.project_name(), 108 version: meson.project_version(), 109 libraries: sdbusplus_dep, 110 description: 'Phosphor snmp utilities', 111) 112 113install_headers( 114 'snmp.hpp', 115 'snmp_notification.hpp', 116 subdir: '.', 117) 118 119build_tests = get_option('tests') 120if not build_tests.disabled() 121 subdir('test') 122endif 123