George Liu | 918e4aa | 2022-05-10 13:59:25 +0800 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-snmp', 'cpp', |
| 3 | version : '1.0.0', |
Patrick Williams | 47652f2 | 2023-07-12 11:15:22 -0500 | [diff] [blame] | 4 | meson_version: '>=1.1.1', |
George Liu | 918e4aa | 2022-05-10 13:59:25 +0800 | [diff] [blame] | 5 | default_options: [ |
| 6 | 'warning_level=3', |
| 7 | 'werror=true', |
Patrick Williams | 47652f2 | 2023-07-12 11:15:22 -0500 | [diff] [blame] | 8 | 'cpp_std=c++23', |
George Liu | 918e4aa | 2022-05-10 13:59:25 +0800 | [diff] [blame] | 9 | 'buildtype=debugoptimized', |
| 10 | ] |
| 11 | ) |
| 12 | |
| 13 | conf_data = configuration_data() |
| 14 | conf_data.set_quoted('BUSNAME_NETWORK_SNMP', 'xyz.openbmc_project.Network.SNMP') |
| 15 | conf_data.set_quoted('OBJ_NETWORK_SNMP', '/xyz/openbmc_project/network/snmp/manager') |
| 16 | conf_data.set_quoted('SNMP_CONF_PERSIST_PATH', '/var/lib/phosphor-snmp/managers/') |
| 17 | conf_data.set('CLASS_VERSION', 1) |
| 18 | |
| 19 | sdbusplus_dep = dependency('sdbusplus') |
| 20 | phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 21 | phosphor_logging_dep = dependency('phosphor-logging') |
| 22 | libsystemd_dep = dependency('libsystemd') |
| 23 | netsnmp_dep = dependency('netsnmp') |
| 24 | libcrypto_dep = dependency('libcrypto') |
| 25 | |
Konstantin Aladyshev | 8de8177 | 2024-04-22 15:49:39 +0300 | [diff] [blame] | 26 | cpp = meson.get_compiler('cpp') |
| 27 | |
| 28 | # Get Cereal dependency. |
| 29 | cereal_dep = dependency('cereal', required: false) |
| 30 | has_cereal = cpp.has_header_symbol( |
| 31 | 'cereal/cereal.hpp', |
| 32 | 'cereal::specialize', |
| 33 | dependencies: cereal_dep, |
| 34 | required: false) |
| 35 | if 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') |
| 44 | endif |
| 45 | |
George Liu | 918e4aa | 2022-05-10 13:59:25 +0800 | [diff] [blame] | 46 | snmp_headers = include_directories('.') |
| 47 | |
| 48 | deps = [ |
| 49 | libsystemd_dep, |
| 50 | phosphor_dbus_interfaces_dep, |
| 51 | phosphor_logging_dep, |
| 52 | sdbusplus_dep, |
Konstantin Aladyshev | 8de8177 | 2024-04-22 15:49:39 +0300 | [diff] [blame] | 53 | cereal_dep, |
George Liu | 918e4aa | 2022-05-10 13:59:25 +0800 | [diff] [blame] | 54 | ] |
| 55 | |
| 56 | sources = [ |
| 57 | 'snmp_main.cpp', |
| 58 | 'snmp_conf_manager.cpp', |
| 59 | 'snmp_client.cpp', |
| 60 | 'snmp_util.cpp', |
| 61 | 'snmp_serialize.cpp', |
| 62 | ] |
| 63 | |
| 64 | configure_file(output: 'config.h', |
| 65 | configuration: conf_data |
| 66 | ) |
| 67 | |
| 68 | executable( |
| 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 | |
| 77 | libsnmp_deps = [ |
| 78 | sdbusplus_dep, |
| 79 | phosphor_logging_dep, |
| 80 | phosphor_dbus_interfaces_dep, |
| 81 | netsnmp_dep, |
| 82 | libcrypto_dep, |
| 83 | ] |
| 84 | |
| 85 | libsnmp_sources = files( |
| 86 | 'snmp_notification.cpp', |
| 87 | 'snmp_util.cpp', |
| 88 | ) |
| 89 | |
| 90 | libsnmp_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 | |
| 100 | phosphor_snmp_dep = declare_dependency( |
| 101 | include_directories: snmp_headers, |
| 102 | link_with: libsnmp_lib, |
| 103 | ) |
| 104 | |
| 105 | import('pkgconfig').generate( |
| 106 | libsnmp_lib, |
| 107 | name: meson.project_name(), |
| 108 | version: meson.project_version(), |
Konstantin Aladyshev | 673d9ce | 2024-03-29 16:08:19 +0300 | [diff] [blame] | 109 | libraries: sdbusplus_dep, |
George Liu | 918e4aa | 2022-05-10 13:59:25 +0800 | [diff] [blame] | 110 | description: 'Phosphor snmp utilities', |
| 111 | ) |
| 112 | |
| 113 | install_headers( |
| 114 | 'snmp.hpp', |
| 115 | 'snmp_notification.hpp', |
| 116 | subdir: '.', |
| 117 | ) |
| 118 | |
George Liu | 208acee | 2022-05-10 14:01:30 +0800 | [diff] [blame] | 119 | build_tests = get_option('tests') |
| 120 | if not build_tests.disabled() |
| 121 | subdir('test') |
| 122 | endif |