blob: 838d8aa55ecddd87b7d72a8ef1556e77d9326528 [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 Bishop1d706372025-07-09 16:39:15 -040016cli11 = dependency('CLI11', required: false, include_type: 'system')
17if not cli11.found()
18 cli11_proj = subproject('cli11', required: true)
19 cli11 = cli11_proj.get_variable('CLI11_dep')
20 cli11 = cli11.as_system('system')
Brad Bishop8c243622022-07-11 11:21:50 -040021endif
Brad Bishop1d706372025-07-09 16:39:15 -040022
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',
Brad Bishope833e0b2025-07-15 09:51:44 -040028 version: '>=1.87.0',
Patrick Williams2a1ef012025-03-03 11:09:20 -050029 required: false,
30 include_type: 'system',
31)
Ed Tanous26ed4a12022-07-13 13:46:08 -070032if not boost.found()
Brad Bishope833e0b2025-07-15 09:51:44 -040033 cmake = import('cmake')
34 opt = cmake.subproject_options()
35 boost_libs = ['asio', 'callable_traits']
36 opt.add_cmake_defines({'BOOST_INCLUDE_LIBRARIES': ';'.join(boost_libs)})
37
38 boost_deps = []
39 boost_proj = cmake.subproject('boost', required: true, options: opt)
40 foreach boost_lib : boost_libs
41 boost_lib_instance = boost_proj.dependency('boost_' + boost_lib).as_system()
42 boost_deps += [boost_lib_instance]
43 endforeach
44 boost = declare_dependency(dependencies: boost_deps)
Ed Tanous26ed4a12022-07-13 13:46:08 -070045endif
Ed Tanous41ad8382025-02-13 17:00:14 -080046add_project_arguments(
Patrick Williams2a1ef012025-03-03 11:09:20 -050047 ['-DBOOST_ASIO_DISABLE_THREADS', '-DBOOST_ASIO_NO_DEPRECATED'],
Ed Tanous41ad8382025-02-13 17:00:14 -080048 language: 'cpp',
49)
Brad Bishopd6aa5522022-05-31 19:23:48 -040050
51if get_option('buildtype').startswith('debug')
Patrick Williams2a1ef012025-03-03 11:09:20 -050052 add_project_arguments('-DMAPPER_ENABLE_DEBUG', language: 'cpp')
Brad Bishopd6aa5522022-05-31 19:23:48 -040053endif
54
Patrick Williamsec874072023-11-29 06:45:19 -060055if get_option('tests').allowed()
Brad Bishopf3fe0db2025-07-09 16:33:11 -040056 gtest = dependency(
57 'gtest_main',
58 main: true,
59 version: '>=1.15.2',
60 required: true,
61 )
62 gmock = dependency('gmock', required: true)
Brad Bishop0aa15902019-05-08 21:30:01 -040063 subdir('src/test')
64 subdir('libmapper/test')
65endif
66
Brad Bishop0aa15902019-05-08 21:30:01 -040067install_headers('libmapper/mapper.h')
68
69libmapper = library(
70 'mapper',
71 'libmapper/mapper.c',
Patrick Williams2a1ef012025-03-03 11:09:20 -050072 dependencies: [dependency('libsystemd')],
Brad Bishop0aa15902019-05-08 21:30:01 -040073 gnu_symbol_visibility: 'hidden',
74 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -050075 install: true,
76)
Brad Bishop0aa15902019-05-08 21:30:01 -040077
Patrick Williamsd4887752022-06-16 11:29:08 -050078mapper_dep = declare_dependency(
79 link_with: libmapper,
80 include_directories: include_directories('libmapper'),
Patrick Williams2a1ef012025-03-03 11:09:20 -050081 dependencies: [dependency('libsystemd')],
Patrick Williamsd4887752022-06-16 11:29:08 -050082)
83
Brad Bishop0aa15902019-05-08 21:30:01 -040084import('pkgconfig').generate(
85 name: 'libmapper',
86 description: 'OpenBMC service discovery utility library',
87 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -050088 libraries: libmapper,
89)
Brad Bishop0aa15902019-05-08 21:30:01 -040090
91executable(
92 'mapper',
93 'libmapper/app.c',
94 link_with: libmapper,
Patrick Williams2a1ef012025-03-03 11:09:20 -050095 dependencies: [dependency('libsystemd')],
96 install: true,
97)
Brad Bishop0aa15902019-05-08 21:30:01 -040098
Andrew Jefferyfb853662024-05-03 14:54:11 +093099mapperx = executable(
Brad Bishop0aa15902019-05-08 21:30:01 -0400100 'mapperx',
101 [
102 'src/main.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400103 'src/processing.cpp',
104 'src/associations.cpp',
Willy Tuaba14d32023-01-31 14:19:59 -0800105 'src/handler.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400106 ],
107 dependencies: [
Ed Tanous26ed4a12022-07-13 13:46:08 -0700108 boost,
Brad Bishop0aa15902019-05-08 21:30:01 -0400109 dependency('libsystemd'),
Brad Bishop5962db52022-05-16 21:04:05 -0400110 phosphor_dbus_interfaces,
Brad Bishop0aa15902019-05-08 21:30:01 -0400111 sdbusplus,
Brad Bishop0aa15902019-05-08 21:30:01 -0400112 dependency('threads'),
Konstantin Aladyshev883d91d2024-04-03 12:38:37 +0300113 dependency('tinyxml2', default_options: ['tests=false']),
Brad Bishop0aa15902019-05-08 21:30:01 -0400114 ],
Brad Bishop13cf45f2025-07-14 16:35:13 -0400115 implicit_include_directories: false,
Brad Bishop2ec91572022-06-03 08:52:11 -0400116 install: true,
117 install_dir: join_paths(
Patrick Williams2a1ef012025-03-03 11:09:20 -0500118 get_option('prefix'),
119 get_option('libexecdir'),
120 meson.project_name(),
121 ),
Brad Bishop0aa15902019-05-08 21:30:01 -0400122)
Andrew Jefferyfb853662024-05-03 14:54:11 +0930123meson.override_find_program('mapperx', mapperx)
Brad Bishop0aa15902019-05-08 21:30:01 -0400124
Brad Bishop2ec91572022-06-03 08:52:11 -0400125systemd_system_unit_dir = dependency('systemd').get_variable(
Patrick Williamsfcae5262025-07-09 11:27:59 -0400126 'systemd_system_unit_dir',
Brad Bishop2ec91572022-06-03 08:52:11 -0400127)
128
129conf = configuration_data()
130conf.set('BINDIR', join_paths(get_option('prefix'), get_option('bindir')))
Patrick Williams2a1ef012025-03-03 11:09:20 -0500131conf.set(
132 'LIBEXECDIR',
133 join_paths(get_option('prefix'), get_option('libexecdir')),
134)
Brad Bishop2ec91572022-06-03 08:52:11 -0400135
136unit_files = [
137 'xyz.openbmc_project.ObjectMapper.service',
138 'mapper-subtree-remove@.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500139 'mapper-wait@.service',
Brad Bishop2ec91572022-06-03 08:52:11 -0400140]
141
142foreach u : unit_files
143 configure_file(
144 configuration: conf,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500145 input: join_paths('src/systemd', u) + '.in',
146 install: true,
Brad Bishop2ec91572022-06-03 08:52:11 -0400147 install_dir: systemd_system_unit_dir,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500148 output: u,
Brad Bishop2ec91572022-06-03 08:52:11 -0400149 )
150endforeach
151
152dbus_system_bus_services_dir = dependency('dbus-1').get_variable(
Patrick Williams40302742023-04-12 08:01:37 -0500153 'system_bus_services_dir',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500154 pkgconfig_define: ['prefix', get_option('prefix')],
Brad Bishop2ec91572022-06-03 08:52:11 -0400155)
156
157install_data(
158 'src/dbus/xyz.openbmc_project.ObjectMapper.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500159 install_dir: dbus_system_bus_services_dir,
160)
Brad Bishop2ec91572022-06-03 08:52:11 -0400161
162install_data(
163 'src/dbus/xyz.openbmc_project.ObjectMapper.conf',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500164 install_dir: get_option('datadir') / 'dbus-1' / 'system.d',
165)
Brad Bishop2ec91572022-06-03 08:52:11 -0400166
Brad Bishop42e5aee2023-02-03 13:57:33 -0500167if not get_option('unit-failure-monitor').disabled()
168 executable(
169 'phosphor-unit-failure-monitor',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500170 ['fail-monitor/main.cpp', 'fail-monitor/monitor.cpp'],
Brad Bishop0426f312025-07-14 16:23:53 -0400171 dependencies: [cli11, phosphor_logging, sdbusplus],
Brad Bishop13cf45f2025-07-14 16:35:13 -0400172 implicit_include_directories: false,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500173 install: true,
Brad Bishop42e5aee2023-02-03 13:57:33 -0500174 )
175endif