blob: d7b8132ff8e0848be47689a011d4d5895e94eed5 [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',
Brad Bishop11c0cc32025-07-08 16:04:25 -040035 '-Wshadow',
Brad Bishop4129bfa2025-07-15 13:43:16 -040036 language: 'cpp',
37 )
Brad Bishopebff1602025-07-15 13:38:34 -040038endif
39
Brad Bishop8f809dc2025-07-15 13:18:56 -040040# Enable debugging for debug builds
41if get_option('buildtype').startswith('debug')
42 add_project_arguments('-DMAPPER_ENABLE_DEBUG', language: 'cpp')
43endif
44
45# Boost configuration
46add_project_arguments(
47 ['-DBOOST_ASIO_DISABLE_THREADS', '-DBOOST_ASIO_NO_DEPRECATED'],
48 language: 'cpp',
49)
50
Brad Bishop1d706372025-07-09 16:39:15 -040051cli11 = dependency('CLI11', required: false, include_type: 'system')
52if not cli11.found()
53 cli11_proj = subproject('cli11', required: true)
54 cli11 = cli11_proj.get_variable('CLI11_dep')
55 cli11 = cli11.as_system('system')
Brad Bishop8c243622022-07-11 11:21:50 -040056endif
Brad Bishop1d706372025-07-09 16:39:15 -040057
Patrick Williamsf814e5b2022-03-21 11:14:17 -050058phosphor_logging = dependency('phosphor-logging')
Brad Bishop5962db52022-05-16 21:04:05 -040059phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
Patrick Williamsf814e5b2022-03-21 11:14:17 -050060sdbusplus = dependency('sdbusplus')
Patrick Williams2a1ef012025-03-03 11:09:20 -050061boost = dependency(
62 'boost',
Brad Bishope833e0b2025-07-15 09:51:44 -040063 version: '>=1.87.0',
Patrick Williams2a1ef012025-03-03 11:09:20 -050064 required: false,
65 include_type: 'system',
66)
Ed Tanous26ed4a12022-07-13 13:46:08 -070067if not boost.found()
Brad Bishope833e0b2025-07-15 09:51:44 -040068 cmake = import('cmake')
69 opt = cmake.subproject_options()
70 boost_libs = ['asio', 'callable_traits']
71 opt.add_cmake_defines({'BOOST_INCLUDE_LIBRARIES': ';'.join(boost_libs)})
72
73 boost_deps = []
74 boost_proj = cmake.subproject('boost', required: true, options: opt)
75 foreach boost_lib : boost_libs
76 boost_lib_instance = boost_proj.dependency('boost_' + boost_lib).as_system()
77 boost_deps += [boost_lib_instance]
78 endforeach
79 boost = declare_dependency(dependencies: boost_deps)
Ed Tanous26ed4a12022-07-13 13:46:08 -070080endif
Brad Bishopd6aa5522022-05-31 19:23:48 -040081
Patrick Williamsec874072023-11-29 06:45:19 -060082if get_option('tests').allowed()
Brad Bishopf3fe0db2025-07-09 16:33:11 -040083 gtest = dependency(
84 'gtest_main',
85 main: true,
86 version: '>=1.15.2',
87 required: true,
88 )
89 gmock = dependency('gmock', required: true)
Brad Bishop0aa15902019-05-08 21:30:01 -040090 subdir('src/test')
91 subdir('libmapper/test')
92endif
93
Brad Bishop0aa15902019-05-08 21:30:01 -040094install_headers('libmapper/mapper.h')
95
96libmapper = library(
97 'mapper',
98 'libmapper/mapper.c',
Patrick Williams2a1ef012025-03-03 11:09:20 -050099 dependencies: [dependency('libsystemd')],
Brad Bishop0aa15902019-05-08 21:30:01 -0400100 gnu_symbol_visibility: 'hidden',
101 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -0500102 install: true,
103)
Brad Bishop0aa15902019-05-08 21:30:01 -0400104
Patrick Williamsd4887752022-06-16 11:29:08 -0500105mapper_dep = declare_dependency(
106 link_with: libmapper,
107 include_directories: include_directories('libmapper'),
Patrick Williams2a1ef012025-03-03 11:09:20 -0500108 dependencies: [dependency('libsystemd')],
Patrick Williamsd4887752022-06-16 11:29:08 -0500109)
110
Brad Bishop0aa15902019-05-08 21:30:01 -0400111import('pkgconfig').generate(
112 name: 'libmapper',
113 description: 'OpenBMC service discovery utility library',
114 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -0500115 libraries: libmapper,
116)
Brad Bishop0aa15902019-05-08 21:30:01 -0400117
118executable(
119 'mapper',
120 'libmapper/app.c',
121 link_with: libmapper,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500122 dependencies: [dependency('libsystemd')],
123 install: true,
124)
Brad Bishop0aa15902019-05-08 21:30:01 -0400125
Andrew Jefferyfb853662024-05-03 14:54:11 +0930126mapperx = executable(
Brad Bishop0aa15902019-05-08 21:30:01 -0400127 'mapperx',
128 [
129 'src/main.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400130 'src/processing.cpp',
131 'src/associations.cpp',
Willy Tuaba14d32023-01-31 14:19:59 -0800132 'src/handler.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400133 ],
134 dependencies: [
Ed Tanous26ed4a12022-07-13 13:46:08 -0700135 boost,
Brad Bishop0aa15902019-05-08 21:30:01 -0400136 dependency('libsystemd'),
Brad Bishop5962db52022-05-16 21:04:05 -0400137 phosphor_dbus_interfaces,
Brad Bishop0aa15902019-05-08 21:30:01 -0400138 sdbusplus,
Brad Bishop0aa15902019-05-08 21:30:01 -0400139 dependency('threads'),
Konstantin Aladyshev883d91d2024-04-03 12:38:37 +0300140 dependency('tinyxml2', default_options: ['tests=false']),
Brad Bishop0aa15902019-05-08 21:30:01 -0400141 ],
Brad Bishop13cf45f2025-07-14 16:35:13 -0400142 implicit_include_directories: false,
Brad Bishop2ec91572022-06-03 08:52:11 -0400143 install: true,
144 install_dir: join_paths(
Patrick Williams2a1ef012025-03-03 11:09:20 -0500145 get_option('prefix'),
146 get_option('libexecdir'),
147 meson.project_name(),
148 ),
Brad Bishop0aa15902019-05-08 21:30:01 -0400149)
Andrew Jefferyfb853662024-05-03 14:54:11 +0930150meson.override_find_program('mapperx', mapperx)
Brad Bishop0aa15902019-05-08 21:30:01 -0400151
Brad Bishop2ec91572022-06-03 08:52:11 -0400152systemd_system_unit_dir = dependency('systemd').get_variable(
Patrick Williamsfcae5262025-07-09 11:27:59 -0400153 'systemd_system_unit_dir',
Brad Bishop2ec91572022-06-03 08:52:11 -0400154)
155
156conf = configuration_data()
157conf.set('BINDIR', join_paths(get_option('prefix'), get_option('bindir')))
Patrick Williams2a1ef012025-03-03 11:09:20 -0500158conf.set(
159 'LIBEXECDIR',
160 join_paths(get_option('prefix'), get_option('libexecdir')),
161)
Brad Bishop2ec91572022-06-03 08:52:11 -0400162
163unit_files = [
164 'xyz.openbmc_project.ObjectMapper.service',
165 'mapper-subtree-remove@.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500166 'mapper-wait@.service',
Brad Bishop2ec91572022-06-03 08:52:11 -0400167]
168
169foreach u : unit_files
170 configure_file(
171 configuration: conf,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500172 input: join_paths('src/systemd', u) + '.in',
173 install: true,
Brad Bishop2ec91572022-06-03 08:52:11 -0400174 install_dir: systemd_system_unit_dir,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500175 output: u,
Brad Bishop2ec91572022-06-03 08:52:11 -0400176 )
177endforeach
178
179dbus_system_bus_services_dir = dependency('dbus-1').get_variable(
Patrick Williams40302742023-04-12 08:01:37 -0500180 'system_bus_services_dir',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500181 pkgconfig_define: ['prefix', get_option('prefix')],
Brad Bishop2ec91572022-06-03 08:52:11 -0400182)
183
184install_data(
185 'src/dbus/xyz.openbmc_project.ObjectMapper.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500186 install_dir: dbus_system_bus_services_dir,
187)
Brad Bishop2ec91572022-06-03 08:52:11 -0400188
189install_data(
190 'src/dbus/xyz.openbmc_project.ObjectMapper.conf',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500191 install_dir: get_option('datadir') / 'dbus-1' / 'system.d',
192)
Brad Bishop2ec91572022-06-03 08:52:11 -0400193
Brad Bishop42e5aee2023-02-03 13:57:33 -0500194if not get_option('unit-failure-monitor').disabled()
195 executable(
196 'phosphor-unit-failure-monitor',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500197 ['fail-monitor/main.cpp', 'fail-monitor/monitor.cpp'],
Brad Bishop0426f312025-07-14 16:23:53 -0400198 dependencies: [cli11, phosphor_logging, sdbusplus],
Brad Bishop13cf45f2025-07-14 16:35:13 -0400199 implicit_include_directories: false,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500200 install: true,
Brad Bishop42e5aee2023-02-03 13:57:33 -0500201 )
202endif