blob: 4508e205003b6a7ce041deaf5f881cf850854d2a [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',
Brad Bishop197de182025-07-09 14:41:37 -040026 '-Wconversion',
Brad Bishop4129bfa2025-07-15 13:43:16 -040027 '-Woverloaded-virtual',
Brad Bishop197de182025-07-09 14:41:37 -040028 '-Wsign-conversion',
Brad Bishop4129bfa2025-07-15 13:43:16 -040029 '-Wunused',
30 '-Wduplicated-cond',
31 '-Wduplicated-branches',
32 '-Wlogical-op',
33 '-Wunused-parameter',
34 '-Wdouble-promotion',
35 language: 'cpp',
36 )
Brad Bishopebff1602025-07-15 13:38:34 -040037endif
38
Brad Bishop8f809dc2025-07-15 13:18:56 -040039# Enable debugging for debug builds
40if get_option('buildtype').startswith('debug')
41 add_project_arguments('-DMAPPER_ENABLE_DEBUG', language: 'cpp')
42endif
43
44# Boost configuration
45add_project_arguments(
46 ['-DBOOST_ASIO_DISABLE_THREADS', '-DBOOST_ASIO_NO_DEPRECATED'],
47 language: 'cpp',
48)
49
Brad Bishop1d706372025-07-09 16:39:15 -040050cli11 = dependency('CLI11', required: false, include_type: 'system')
51if not cli11.found()
52 cli11_proj = subproject('cli11', required: true)
53 cli11 = cli11_proj.get_variable('CLI11_dep')
54 cli11 = cli11.as_system('system')
Brad Bishop8c243622022-07-11 11:21:50 -040055endif
Brad Bishop1d706372025-07-09 16:39:15 -040056
Patrick Williamsf814e5b2022-03-21 11:14:17 -050057phosphor_logging = dependency('phosphor-logging')
Brad Bishop5962db52022-05-16 21:04:05 -040058phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
Patrick Williamsf814e5b2022-03-21 11:14:17 -050059sdbusplus = dependency('sdbusplus')
Patrick Williams2a1ef012025-03-03 11:09:20 -050060boost = dependency(
61 'boost',
Brad Bishope833e0b2025-07-15 09:51:44 -040062 version: '>=1.87.0',
Patrick Williams2a1ef012025-03-03 11:09:20 -050063 required: false,
64 include_type: 'system',
65)
Ed Tanous26ed4a12022-07-13 13:46:08 -070066if not boost.found()
Brad Bishope833e0b2025-07-15 09:51:44 -040067 cmake = import('cmake')
68 opt = cmake.subproject_options()
69 boost_libs = ['asio', 'callable_traits']
70 opt.add_cmake_defines({'BOOST_INCLUDE_LIBRARIES': ';'.join(boost_libs)})
71
72 boost_deps = []
73 boost_proj = cmake.subproject('boost', required: true, options: opt)
74 foreach boost_lib : boost_libs
75 boost_lib_instance = boost_proj.dependency('boost_' + boost_lib).as_system()
76 boost_deps += [boost_lib_instance]
77 endforeach
78 boost = declare_dependency(dependencies: boost_deps)
Ed Tanous26ed4a12022-07-13 13:46:08 -070079endif
Brad Bishopd6aa5522022-05-31 19:23:48 -040080
Patrick Williamsec874072023-11-29 06:45:19 -060081if get_option('tests').allowed()
Brad Bishopf3fe0db2025-07-09 16:33:11 -040082 gtest = dependency(
83 'gtest_main',
84 main: true,
85 version: '>=1.15.2',
86 required: true,
87 )
88 gmock = dependency('gmock', required: true)
Brad Bishop0aa15902019-05-08 21:30:01 -040089 subdir('src/test')
90 subdir('libmapper/test')
91endif
92
Brad Bishop0aa15902019-05-08 21:30:01 -040093install_headers('libmapper/mapper.h')
94
95libmapper = library(
96 'mapper',
97 'libmapper/mapper.c',
Patrick Williams2a1ef012025-03-03 11:09:20 -050098 dependencies: [dependency('libsystemd')],
Brad Bishop0aa15902019-05-08 21:30:01 -040099 gnu_symbol_visibility: 'hidden',
100 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -0500101 install: true,
102)
Brad Bishop0aa15902019-05-08 21:30:01 -0400103
Patrick Williamsd4887752022-06-16 11:29:08 -0500104mapper_dep = declare_dependency(
105 link_with: libmapper,
106 include_directories: include_directories('libmapper'),
Patrick Williams2a1ef012025-03-03 11:09:20 -0500107 dependencies: [dependency('libsystemd')],
Patrick Williamsd4887752022-06-16 11:29:08 -0500108)
109
Brad Bishop0aa15902019-05-08 21:30:01 -0400110import('pkgconfig').generate(
111 name: 'libmapper',
112 description: 'OpenBMC service discovery utility library',
113 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -0500114 libraries: libmapper,
115)
Brad Bishop0aa15902019-05-08 21:30:01 -0400116
117executable(
118 'mapper',
119 'libmapper/app.c',
120 link_with: libmapper,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500121 dependencies: [dependency('libsystemd')],
122 install: true,
123)
Brad Bishop0aa15902019-05-08 21:30:01 -0400124
Andrew Jefferyfb853662024-05-03 14:54:11 +0930125mapperx = executable(
Brad Bishop0aa15902019-05-08 21:30:01 -0400126 'mapperx',
127 [
128 'src/main.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400129 'src/processing.cpp',
130 'src/associations.cpp',
Willy Tuaba14d32023-01-31 14:19:59 -0800131 'src/handler.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400132 ],
133 dependencies: [
Ed Tanous26ed4a12022-07-13 13:46:08 -0700134 boost,
Brad Bishop0aa15902019-05-08 21:30:01 -0400135 dependency('libsystemd'),
Brad Bishop5962db52022-05-16 21:04:05 -0400136 phosphor_dbus_interfaces,
Brad Bishop0aa15902019-05-08 21:30:01 -0400137 sdbusplus,
Brad Bishop0aa15902019-05-08 21:30:01 -0400138 dependency('threads'),
Konstantin Aladyshev883d91d2024-04-03 12:38:37 +0300139 dependency('tinyxml2', default_options: ['tests=false']),
Brad Bishop0aa15902019-05-08 21:30:01 -0400140 ],
Brad Bishop13cf45f2025-07-14 16:35:13 -0400141 implicit_include_directories: false,
Brad Bishop2ec91572022-06-03 08:52:11 -0400142 install: true,
143 install_dir: join_paths(
Patrick Williams2a1ef012025-03-03 11:09:20 -0500144 get_option('prefix'),
145 get_option('libexecdir'),
146 meson.project_name(),
147 ),
Brad Bishop0aa15902019-05-08 21:30:01 -0400148)
Andrew Jefferyfb853662024-05-03 14:54:11 +0930149meson.override_find_program('mapperx', mapperx)
Brad Bishop0aa15902019-05-08 21:30:01 -0400150
Brad Bishop2ec91572022-06-03 08:52:11 -0400151systemd_system_unit_dir = dependency('systemd').get_variable(
Patrick Williamsfcae5262025-07-09 11:27:59 -0400152 'systemd_system_unit_dir',
Brad Bishop2ec91572022-06-03 08:52:11 -0400153)
154
155conf = configuration_data()
156conf.set('BINDIR', join_paths(get_option('prefix'), get_option('bindir')))
Patrick Williams2a1ef012025-03-03 11:09:20 -0500157conf.set(
158 'LIBEXECDIR',
159 join_paths(get_option('prefix'), get_option('libexecdir')),
160)
Brad Bishop2ec91572022-06-03 08:52:11 -0400161
162unit_files = [
163 'xyz.openbmc_project.ObjectMapper.service',
164 'mapper-subtree-remove@.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500165 'mapper-wait@.service',
Brad Bishop2ec91572022-06-03 08:52:11 -0400166]
167
168foreach u : unit_files
169 configure_file(
170 configuration: conf,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500171 input: join_paths('src/systemd', u) + '.in',
172 install: true,
Brad Bishop2ec91572022-06-03 08:52:11 -0400173 install_dir: systemd_system_unit_dir,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500174 output: u,
Brad Bishop2ec91572022-06-03 08:52:11 -0400175 )
176endforeach
177
178dbus_system_bus_services_dir = dependency('dbus-1').get_variable(
Patrick Williams40302742023-04-12 08:01:37 -0500179 'system_bus_services_dir',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500180 pkgconfig_define: ['prefix', get_option('prefix')],
Brad Bishop2ec91572022-06-03 08:52:11 -0400181)
182
183install_data(
184 'src/dbus/xyz.openbmc_project.ObjectMapper.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500185 install_dir: dbus_system_bus_services_dir,
186)
Brad Bishop2ec91572022-06-03 08:52:11 -0400187
188install_data(
189 'src/dbus/xyz.openbmc_project.ObjectMapper.conf',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500190 install_dir: get_option('datadir') / 'dbus-1' / 'system.d',
191)
Brad Bishop2ec91572022-06-03 08:52:11 -0400192
Brad Bishop42e5aee2023-02-03 13:57:33 -0500193if not get_option('unit-failure-monitor').disabled()
194 executable(
195 'phosphor-unit-failure-monitor',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500196 ['fail-monitor/main.cpp', 'fail-monitor/monitor.cpp'],
Brad Bishop0426f312025-07-14 16:23:53 -0400197 dependencies: [cli11, phosphor_logging, sdbusplus],
Brad Bishop13cf45f2025-07-14 16:35:13 -0400198 implicit_include_directories: false,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500199 install: true,
Brad Bishop42e5aee2023-02-03 13:57:33 -0500200 )
201endif