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