blob: 7c4336ef01ec65b305890405fc38b43dd8c593e7 [file] [log] [blame]
Brad Bishop0aa15902019-05-08 21:30:01 -04001project(
2 'phosphor-objmgr',
Patrick Williams2a1ef012025-03-03 11:09:20 -05003 'c',
4 'cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -04005 default_options: [
Brad Bishopd6aa5522022-05-31 19:23:48 -04006 'buildtype=debugoptimized',
Patrick Williams26ed9802023-07-12 11:16:09 -05007 'cpp_std=c++23',
Brad Bishop0aa15902019-05-08 21:30:01 -04008 'warning_level=3',
9 'werror=true',
10 ],
11 license: 'Apache-2.0',
Patrick Williams26ed9802023-07-12 11:16:09 -050012 meson_version: '>=1.1.1',
Brad Bishop0aa15902019-05-08 21:30:01 -040013 version: '1.0',
14)
15
Brad Bishop8c243622022-07-11 11:21:50 -040016cxx = meson.get_compiler('cpp')
17
18if cxx.has_header('CLI/CLI.hpp')
19 cli11_dep = declare_dependency()
20else
21 cli11_dep = dependency('cli11')
22endif
Patrick Williamsf814e5b2022-03-21 11:14:17 -050023phosphor_logging = dependency('phosphor-logging')
Brad Bishop5962db52022-05-16 21:04:05 -040024phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
Patrick Williamsf814e5b2022-03-21 11:14:17 -050025sdbusplus = dependency('sdbusplus')
Patrick Williams2a1ef012025-03-03 11:09:20 -050026boost = dependency(
27 'boost',
28 version: '>=1.79.0',
29 required: false,
30 include_type: 'system',
31)
Ed Tanous26ed4a12022-07-13 13:46:08 -070032if not boost.found()
Patrick Williams2a1ef012025-03-03 11:09:20 -050033 subproject('boost', required: false)
34 boost_inc = include_directories('subprojects/boost_1_79_0/', is_system: true)
35 boost = declare_dependency(include_directories: boost_inc)
36 boost = boost.as_system('system')
Ed Tanous26ed4a12022-07-13 13:46:08 -070037endif
Ed Tanous41ad8382025-02-13 17:00:14 -080038add_project_arguments(
Patrick Williams2a1ef012025-03-03 11:09:20 -050039 ['-DBOOST_ASIO_DISABLE_THREADS', '-DBOOST_ASIO_NO_DEPRECATED'],
Ed Tanous41ad8382025-02-13 17:00:14 -080040 language: 'cpp',
41)
Brad Bishopd6aa5522022-05-31 19:23:48 -040042
43if get_option('buildtype').startswith('debug')
Patrick Williams2a1ef012025-03-03 11:09:20 -050044 add_project_arguments('-DMAPPER_ENABLE_DEBUG', language: 'cpp')
Brad Bishopd6aa5522022-05-31 19:23:48 -040045endif
46
Patrick Williamsec874072023-11-29 06:45:19 -060047if get_option('tests').allowed()
Brad Bishopf3fe0db2025-07-09 16:33:11 -040048 gtest = dependency(
49 'gtest_main',
50 main: true,
51 version: '>=1.15.2',
52 required: true,
53 )
54 gmock = dependency('gmock', required: true)
Brad Bishop0aa15902019-05-08 21:30:01 -040055 subdir('src/test')
56 subdir('libmapper/test')
57endif
58
Brad Bishop0aa15902019-05-08 21:30:01 -040059install_headers('libmapper/mapper.h')
60
61libmapper = library(
62 'mapper',
63 'libmapper/mapper.c',
Patrick Williams2a1ef012025-03-03 11:09:20 -050064 dependencies: [dependency('libsystemd')],
Brad Bishop0aa15902019-05-08 21:30:01 -040065 gnu_symbol_visibility: 'hidden',
66 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -050067 install: true,
68)
Brad Bishop0aa15902019-05-08 21:30:01 -040069
Patrick Williamsd4887752022-06-16 11:29:08 -050070mapper_dep = declare_dependency(
71 link_with: libmapper,
72 include_directories: include_directories('libmapper'),
Patrick Williams2a1ef012025-03-03 11:09:20 -050073 dependencies: [dependency('libsystemd')],
Patrick Williamsd4887752022-06-16 11:29:08 -050074)
75
Brad Bishop0aa15902019-05-08 21:30:01 -040076import('pkgconfig').generate(
77 name: 'libmapper',
78 description: 'OpenBMC service discovery utility library',
79 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -050080 libraries: libmapper,
81)
Brad Bishop0aa15902019-05-08 21:30:01 -040082
83executable(
84 'mapper',
85 'libmapper/app.c',
86 link_with: libmapper,
Patrick Williams2a1ef012025-03-03 11:09:20 -050087 dependencies: [dependency('libsystemd')],
88 install: true,
89)
Brad Bishop0aa15902019-05-08 21:30:01 -040090
Andrew Jefferyfb853662024-05-03 14:54:11 +093091mapperx = executable(
Brad Bishop0aa15902019-05-08 21:30:01 -040092 'mapperx',
93 [
94 'src/main.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -040095 'src/processing.cpp',
96 'src/associations.cpp',
Willy Tuaba14d32023-01-31 14:19:59 -080097 'src/handler.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -040098 ],
99 dependencies: [
Ed Tanous26ed4a12022-07-13 13:46:08 -0700100 boost,
Brad Bishop0aa15902019-05-08 21:30:01 -0400101 dependency('libsystemd'),
Brad Bishop5962db52022-05-16 21:04:05 -0400102 phosphor_dbus_interfaces,
Brad Bishop0aa15902019-05-08 21:30:01 -0400103 phosphor_logging,
104 sdbusplus,
Brad Bishop0aa15902019-05-08 21:30:01 -0400105 dependency('threads'),
Konstantin Aladyshev883d91d2024-04-03 12:38:37 +0300106 dependency('tinyxml2', default_options: ['tests=false']),
Brad Bishop0aa15902019-05-08 21:30:01 -0400107 ],
Brad Bishop2ec91572022-06-03 08:52:11 -0400108 install: true,
109 install_dir: join_paths(
Patrick Williams2a1ef012025-03-03 11:09:20 -0500110 get_option('prefix'),
111 get_option('libexecdir'),
112 meson.project_name(),
113 ),
Brad Bishop0aa15902019-05-08 21:30:01 -0400114)
Andrew Jefferyfb853662024-05-03 14:54:11 +0930115meson.override_find_program('mapperx', mapperx)
Brad Bishop0aa15902019-05-08 21:30:01 -0400116
Brad Bishop2ec91572022-06-03 08:52:11 -0400117systemd_system_unit_dir = dependency('systemd').get_variable(
Patrick Williamsfcae5262025-07-09 11:27:59 -0400118 'systemd_system_unit_dir',
Brad Bishop2ec91572022-06-03 08:52:11 -0400119)
120
121conf = configuration_data()
122conf.set('BINDIR', join_paths(get_option('prefix'), get_option('bindir')))
Patrick Williams2a1ef012025-03-03 11:09:20 -0500123conf.set(
124 'LIBEXECDIR',
125 join_paths(get_option('prefix'), get_option('libexecdir')),
126)
Brad Bishop2ec91572022-06-03 08:52:11 -0400127
128unit_files = [
129 'xyz.openbmc_project.ObjectMapper.service',
130 'mapper-subtree-remove@.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500131 'mapper-wait@.service',
Brad Bishop2ec91572022-06-03 08:52:11 -0400132]
133
134foreach u : unit_files
135 configure_file(
136 configuration: conf,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500137 input: join_paths('src/systemd', u) + '.in',
138 install: true,
Brad Bishop2ec91572022-06-03 08:52:11 -0400139 install_dir: systemd_system_unit_dir,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500140 output: u,
Brad Bishop2ec91572022-06-03 08:52:11 -0400141 )
142endforeach
143
144dbus_system_bus_services_dir = dependency('dbus-1').get_variable(
Patrick Williams40302742023-04-12 08:01:37 -0500145 'system_bus_services_dir',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500146 pkgconfig_define: ['prefix', get_option('prefix')],
Brad Bishop2ec91572022-06-03 08:52:11 -0400147)
148
149install_data(
150 'src/dbus/xyz.openbmc_project.ObjectMapper.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500151 install_dir: dbus_system_bus_services_dir,
152)
Brad Bishop2ec91572022-06-03 08:52:11 -0400153
154install_data(
155 'src/dbus/xyz.openbmc_project.ObjectMapper.conf',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500156 install_dir: get_option('datadir') / 'dbus-1' / 'system.d',
157)
Brad Bishop2ec91572022-06-03 08:52:11 -0400158
Brad Bishop42e5aee2023-02-03 13:57:33 -0500159if not get_option('unit-failure-monitor').disabled()
160 executable(
161 'phosphor-unit-failure-monitor',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500162 ['fail-monitor/main.cpp', 'fail-monitor/monitor.cpp'],
163 dependencies: [cli11_dep, phosphor_logging],
164 install: true,
Brad Bishop42e5aee2023-02-03 13:57:33 -0500165 )
166endif