blob: 794527670e4f75ac17ef09a1e3d8131c8b2605df [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 Bishopebff1602025-07-15 13:38:34 -040016cxx = meson.get_compiler('cpp')
17
18if (cxx.get_id() == 'gcc')
19 if (cxx.version().version_compare('<13.0'))
20 error('This project requires gcc-13 or higher')
21 endif
Brad Bishop4129bfa2025-07-15 13:43:16 -040022
23 add_project_arguments(
24 '-Wformat=2',
25 '-Wcast-align',
26 '-Woverloaded-virtual',
27 '-Wunused',
28 '-Wduplicated-cond',
29 '-Wduplicated-branches',
30 '-Wlogical-op',
31 '-Wunused-parameter',
32 '-Wdouble-promotion',
33 language: 'cpp',
34 )
Brad Bishopebff1602025-07-15 13:38:34 -040035endif
36
Brad Bishop8f809dc2025-07-15 13:18:56 -040037# Enable debugging for debug builds
38if get_option('buildtype').startswith('debug')
39 add_project_arguments('-DMAPPER_ENABLE_DEBUG', language: 'cpp')
40endif
41
42# Boost configuration
43add_project_arguments(
44 ['-DBOOST_ASIO_DISABLE_THREADS', '-DBOOST_ASIO_NO_DEPRECATED'],
45 language: 'cpp',
46)
47
Brad Bishop1d706372025-07-09 16:39:15 -040048cli11 = dependency('CLI11', required: false, include_type: 'system')
49if not cli11.found()
50 cli11_proj = subproject('cli11', required: true)
51 cli11 = cli11_proj.get_variable('CLI11_dep')
52 cli11 = cli11.as_system('system')
Brad Bishop8c243622022-07-11 11:21:50 -040053endif
Brad Bishop1d706372025-07-09 16:39:15 -040054
Patrick Williamsf814e5b2022-03-21 11:14:17 -050055phosphor_logging = dependency('phosphor-logging')
Brad Bishop5962db52022-05-16 21:04:05 -040056phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
Patrick Williamsf814e5b2022-03-21 11:14:17 -050057sdbusplus = dependency('sdbusplus')
Patrick Williams2a1ef012025-03-03 11:09:20 -050058boost = dependency(
59 'boost',
Brad Bishope833e0b2025-07-15 09:51:44 -040060 version: '>=1.87.0',
Patrick Williams2a1ef012025-03-03 11:09:20 -050061 required: false,
62 include_type: 'system',
63)
Ed Tanous26ed4a12022-07-13 13:46:08 -070064if not boost.found()
Brad Bishope833e0b2025-07-15 09:51:44 -040065 cmake = import('cmake')
66 opt = cmake.subproject_options()
67 boost_libs = ['asio', 'callable_traits']
68 opt.add_cmake_defines({'BOOST_INCLUDE_LIBRARIES': ';'.join(boost_libs)})
69
70 boost_deps = []
71 boost_proj = cmake.subproject('boost', required: true, options: opt)
72 foreach boost_lib : boost_libs
73 boost_lib_instance = boost_proj.dependency('boost_' + boost_lib).as_system()
74 boost_deps += [boost_lib_instance]
75 endforeach
76 boost = declare_dependency(dependencies: boost_deps)
Ed Tanous26ed4a12022-07-13 13:46:08 -070077endif
Brad Bishopd6aa5522022-05-31 19:23:48 -040078
Patrick Williamsec874072023-11-29 06:45:19 -060079if get_option('tests').allowed()
Brad Bishopf3fe0db2025-07-09 16:33:11 -040080 gtest = dependency(
81 'gtest_main',
82 main: true,
83 version: '>=1.15.2',
84 required: true,
85 )
86 gmock = dependency('gmock', required: true)
Brad Bishop0aa15902019-05-08 21:30:01 -040087 subdir('src/test')
88 subdir('libmapper/test')
89endif
90
Brad Bishop0aa15902019-05-08 21:30:01 -040091install_headers('libmapper/mapper.h')
92
93libmapper = library(
94 'mapper',
95 'libmapper/mapper.c',
Patrick Williams2a1ef012025-03-03 11:09:20 -050096 dependencies: [dependency('libsystemd')],
Brad Bishop0aa15902019-05-08 21:30:01 -040097 gnu_symbol_visibility: 'hidden',
98 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -050099 install: true,
100)
Brad Bishop0aa15902019-05-08 21:30:01 -0400101
Patrick Williamsd4887752022-06-16 11:29:08 -0500102mapper_dep = declare_dependency(
103 link_with: libmapper,
104 include_directories: include_directories('libmapper'),
Patrick Williams2a1ef012025-03-03 11:09:20 -0500105 dependencies: [dependency('libsystemd')],
Patrick Williamsd4887752022-06-16 11:29:08 -0500106)
107
Brad Bishop0aa15902019-05-08 21:30:01 -0400108import('pkgconfig').generate(
109 name: 'libmapper',
110 description: 'OpenBMC service discovery utility library',
111 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -0500112 libraries: libmapper,
113)
Brad Bishop0aa15902019-05-08 21:30:01 -0400114
115executable(
116 'mapper',
117 'libmapper/app.c',
118 link_with: libmapper,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500119 dependencies: [dependency('libsystemd')],
120 install: true,
121)
Brad Bishop0aa15902019-05-08 21:30:01 -0400122
Andrew Jefferyfb853662024-05-03 14:54:11 +0930123mapperx = executable(
Brad Bishop0aa15902019-05-08 21:30:01 -0400124 'mapperx',
125 [
126 'src/main.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400127 'src/processing.cpp',
128 'src/associations.cpp',
Willy Tuaba14d32023-01-31 14:19:59 -0800129 'src/handler.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400130 ],
131 dependencies: [
Ed Tanous26ed4a12022-07-13 13:46:08 -0700132 boost,
Brad Bishop0aa15902019-05-08 21:30:01 -0400133 dependency('libsystemd'),
Brad Bishop5962db52022-05-16 21:04:05 -0400134 phosphor_dbus_interfaces,
Brad Bishop0aa15902019-05-08 21:30:01 -0400135 sdbusplus,
Brad Bishop0aa15902019-05-08 21:30:01 -0400136 dependency('threads'),
Konstantin Aladyshev883d91d2024-04-03 12:38:37 +0300137 dependency('tinyxml2', default_options: ['tests=false']),
Brad Bishop0aa15902019-05-08 21:30:01 -0400138 ],
Brad Bishop13cf45f2025-07-14 16:35:13 -0400139 implicit_include_directories: false,
Brad Bishop2ec91572022-06-03 08:52:11 -0400140 install: true,
141 install_dir: join_paths(
Patrick Williams2a1ef012025-03-03 11:09:20 -0500142 get_option('prefix'),
143 get_option('libexecdir'),
144 meson.project_name(),
145 ),
Brad Bishop0aa15902019-05-08 21:30:01 -0400146)
Andrew Jefferyfb853662024-05-03 14:54:11 +0930147meson.override_find_program('mapperx', mapperx)
Brad Bishop0aa15902019-05-08 21:30:01 -0400148
Brad Bishop2ec91572022-06-03 08:52:11 -0400149systemd_system_unit_dir = dependency('systemd').get_variable(
Patrick Williamsfcae5262025-07-09 11:27:59 -0400150 'systemd_system_unit_dir',
Brad Bishop2ec91572022-06-03 08:52:11 -0400151)
152
153conf = configuration_data()
154conf.set('BINDIR', join_paths(get_option('prefix'), get_option('bindir')))
Patrick Williams2a1ef012025-03-03 11:09:20 -0500155conf.set(
156 'LIBEXECDIR',
157 join_paths(get_option('prefix'), get_option('libexecdir')),
158)
Brad Bishop2ec91572022-06-03 08:52:11 -0400159
160unit_files = [
161 'xyz.openbmc_project.ObjectMapper.service',
162 'mapper-subtree-remove@.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500163 'mapper-wait@.service',
Brad Bishop2ec91572022-06-03 08:52:11 -0400164]
165
166foreach u : unit_files
167 configure_file(
168 configuration: conf,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500169 input: join_paths('src/systemd', u) + '.in',
170 install: true,
Brad Bishop2ec91572022-06-03 08:52:11 -0400171 install_dir: systemd_system_unit_dir,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500172 output: u,
Brad Bishop2ec91572022-06-03 08:52:11 -0400173 )
174endforeach
175
176dbus_system_bus_services_dir = dependency('dbus-1').get_variable(
Patrick Williams40302742023-04-12 08:01:37 -0500177 'system_bus_services_dir',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500178 pkgconfig_define: ['prefix', get_option('prefix')],
Brad Bishop2ec91572022-06-03 08:52:11 -0400179)
180
181install_data(
182 'src/dbus/xyz.openbmc_project.ObjectMapper.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500183 install_dir: dbus_system_bus_services_dir,
184)
Brad Bishop2ec91572022-06-03 08:52:11 -0400185
186install_data(
187 'src/dbus/xyz.openbmc_project.ObjectMapper.conf',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500188 install_dir: get_option('datadir') / 'dbus-1' / 'system.d',
189)
Brad Bishop2ec91572022-06-03 08:52:11 -0400190
Brad Bishop42e5aee2023-02-03 13:57:33 -0500191if not get_option('unit-failure-monitor').disabled()
192 executable(
193 'phosphor-unit-failure-monitor',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500194 ['fail-monitor/main.cpp', 'fail-monitor/monitor.cpp'],
Brad Bishop0426f312025-07-14 16:23:53 -0400195 dependencies: [cli11, phosphor_logging, sdbusplus],
Brad Bishop13cf45f2025-07-14 16:35:13 -0400196 implicit_include_directories: false,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500197 install: true,
Brad Bishop42e5aee2023-02-03 13:57:33 -0500198 )
199endif