blob: 7e75f8345886038bfb7074764f5bcdb5d215d5ba [file] [log] [blame]
George Liu918e4aa2022-05-10 13:59:25 +08001project(
Patrick Williams0eb16842025-02-01 08:36:50 -05002 'phosphor-snmp',
3 'cpp',
4 version: '1.0.0',
Patrick Williams47652f22023-07-12 11:15:22 -05005 meson_version: '>=1.1.1',
George Liu918e4aa2022-05-10 13:59:25 +08006 default_options: [
7 'warning_level=3',
8 'werror=true',
Patrick Williams47652f22023-07-12 11:15:22 -05009 'cpp_std=c++23',
George Liu918e4aa2022-05-10 13:59:25 +080010 'buildtype=debugoptimized',
Patrick Williams0eb16842025-02-01 08:36:50 -050011 ],
George Liu918e4aa2022-05-10 13:59:25 +080012)
13
14conf_data = configuration_data()
15conf_data.set_quoted('BUSNAME_NETWORK_SNMP', 'xyz.openbmc_project.Network.SNMP')
Patrick Williams0eb16842025-02-01 08:36:50 -050016conf_data.set_quoted(
17 'OBJ_NETWORK_SNMP',
18 '/xyz/openbmc_project/network/snmp/manager',
19)
20conf_data.set_quoted(
21 'SNMP_CONF_PERSIST_PATH',
22 '/var/lib/phosphor-snmp/managers/',
23)
George Liu918e4aa2022-05-10 13:59:25 +080024conf_data.set('CLASS_VERSION', 1)
25
26sdbusplus_dep = dependency('sdbusplus')
27phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
28phosphor_logging_dep = dependency('phosphor-logging')
29libsystemd_dep = dependency('libsystemd')
30netsnmp_dep = dependency('netsnmp')
31libcrypto_dep = dependency('libcrypto')
32
Konstantin Aladyshev8de81772024-04-22 15:49:39 +030033cpp = meson.get_compiler('cpp')
34
35# Get Cereal dependency.
36cereal_dep = dependency('cereal', required: false)
37has_cereal = cpp.has_header_symbol(
38 'cereal/cereal.hpp',
39 'cereal::specialize',
40 dependencies: cereal_dep,
Patrick Williams0eb16842025-02-01 08:36:50 -050041 required: false,
42)
Konstantin Aladyshev8de81772024-04-22 15:49:39 +030043if not has_cereal
44 cereal_opts = import('cmake').subproject_options()
Patrick Williams0eb16842025-02-01 08:36:50 -050045 cereal_opts.add_cmake_defines(
46 {'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'},
47 )
Konstantin Aladyshev8de81772024-04-22 15:49:39 +030048 cereal_proj = import('cmake').subproject(
49 'cereal',
50 options: cereal_opts,
Patrick Williams0eb16842025-02-01 08:36:50 -050051 required: false,
52 )
Konstantin Aladyshev8de81772024-04-22 15:49:39 +030053 assert(cereal_proj.found(), 'cereal is required')
54 cereal_dep = cereal_proj.dependency('cereal')
55endif
56
George Liu918e4aa2022-05-10 13:59:25 +080057snmp_headers = include_directories('.')
58
59deps = [
60 libsystemd_dep,
61 phosphor_dbus_interfaces_dep,
62 phosphor_logging_dep,
63 sdbusplus_dep,
Konstantin Aladyshev8de81772024-04-22 15:49:39 +030064 cereal_dep,
George Liu918e4aa2022-05-10 13:59:25 +080065]
66
67sources = [
68 'snmp_main.cpp',
69 'snmp_conf_manager.cpp',
70 'snmp_client.cpp',
71 'snmp_util.cpp',
72 'snmp_serialize.cpp',
73]
74
Patrick Williams0eb16842025-02-01 08:36:50 -050075configure_file(output: 'config.h', configuration: conf_data)
George Liu918e4aa2022-05-10 13:59:25 +080076
77executable(
78 'phosphor-network-snmpconf',
79 sources,
80 implicit_include_directories: true,
81 dependencies: deps,
82 install: true,
Patrick Williams0eb16842025-02-01 08:36:50 -050083 install_dir: get_option('bindir'),
George Liu918e4aa2022-05-10 13:59:25 +080084)
85
86libsnmp_deps = [
87 sdbusplus_dep,
88 phosphor_logging_dep,
89 phosphor_dbus_interfaces_dep,
90 netsnmp_dep,
91 libcrypto_dep,
92]
93
Patrick Williams0eb16842025-02-01 08:36:50 -050094libsnmp_sources = files('snmp_notification.cpp', 'snmp_util.cpp')
George Liu918e4aa2022-05-10 13:59:25 +080095
96libsnmp_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
106phosphor_snmp_dep = declare_dependency(
107 include_directories: snmp_headers,
108 link_with: libsnmp_lib,
109)
110
111import('pkgconfig').generate(
112 libsnmp_lib,
113 name: meson.project_name(),
114 version: meson.project_version(),
Konstantin Aladyshev673d9ce2024-03-29 16:08:19 +0300115 libraries: sdbusplus_dep,
George Liu918e4aa2022-05-10 13:59:25 +0800116 description: 'Phosphor snmp utilities',
117)
118
Patrick Williams0eb16842025-02-01 08:36:50 -0500119install_headers('snmp.hpp', 'snmp_notification.hpp', subdir: '.')
George Liu918e4aa2022-05-10 13:59:25 +0800120
George Liu208acee2022-05-10 14:01:30 +0800121build_tests = get_option('tests')
122if not build_tests.disabled()
Patrick Williams0eb16842025-02-01 08:36:50 -0500123 subdir('test')
George Liu208acee2022-05-10 14:01:30 +0800124endif