blob: 5506203d968f6c5786d7eafcb3e21ace90ed0102 [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
Brad Bishop9014d222025-07-15 16:16:35 -040018boost_flags = []
19if (cxx.get_id() == 'clang')
20 if (cxx.version().version_compare('<18.0'))
21 error('This project requires clang-18 or higher')
22 endif
23 add_project_arguments(
24# https://github.com/llvm/llvm-project/issues/101614
25 '-fno-builtin-std-forward_like',
26 language: 'cpp',
27 )
28 boost_flags += ['-Wno-strict-prototypes']
29endif
30
Brad Bishopebff1602025-07-15 13:38:34 -040031if (cxx.get_id() == 'gcc')
32 if (cxx.version().version_compare('<13.0'))
33 error('This project requires gcc-13 or higher')
34 endif
Brad Bishop4129bfa2025-07-15 13:43:16 -040035
36 add_project_arguments(
37 '-Wformat=2',
38 '-Wcast-align',
Brad Bishop197de182025-07-09 14:41:37 -040039 '-Wconversion',
Brad Bishop4129bfa2025-07-15 13:43:16 -040040 '-Woverloaded-virtual',
Brad Bishop197de182025-07-09 14:41:37 -040041 '-Wsign-conversion',
Brad Bishop4129bfa2025-07-15 13:43:16 -040042 '-Wunused',
43 '-Wduplicated-cond',
44 '-Wduplicated-branches',
45 '-Wlogical-op',
46 '-Wunused-parameter',
47 '-Wdouble-promotion',
Brad Bishop11c0cc32025-07-08 16:04:25 -040048 '-Wshadow',
Brad Bishop4129bfa2025-07-15 13:43:16 -040049 language: 'cpp',
50 )
Brad Bishopebff1602025-07-15 13:38:34 -040051endif
52
Brad Bishop8f809dc2025-07-15 13:18:56 -040053# Enable debugging for debug builds
54if get_option('buildtype').startswith('debug')
55 add_project_arguments('-DMAPPER_ENABLE_DEBUG', language: 'cpp')
56endif
57
58# Boost configuration
59add_project_arguments(
60 ['-DBOOST_ASIO_DISABLE_THREADS', '-DBOOST_ASIO_NO_DEPRECATED'],
61 language: 'cpp',
62)
63
Brad Bishop1d706372025-07-09 16:39:15 -040064cli11 = dependency('CLI11', required: false, include_type: 'system')
65if not cli11.found()
Brad Bishop5da44442025-10-03 15:00:12 -040066 cli11_proj = subproject('CLI11', required: true)
Brad Bishop1d706372025-07-09 16:39:15 -040067 cli11 = cli11_proj.get_variable('CLI11_dep')
68 cli11 = cli11.as_system('system')
Brad Bishop8c243622022-07-11 11:21:50 -040069endif
Brad Bishop1d706372025-07-09 16:39:15 -040070
Patrick Williamsf814e5b2022-03-21 11:14:17 -050071phosphor_logging = dependency('phosphor-logging')
Brad Bishop5962db52022-05-16 21:04:05 -040072phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
Patrick Williamsf814e5b2022-03-21 11:14:17 -050073sdbusplus = dependency('sdbusplus')
Patrick Williams2a1ef012025-03-03 11:09:20 -050074boost = dependency(
75 'boost',
Brad Bishope833e0b2025-07-15 09:51:44 -040076 version: '>=1.87.0',
Patrick Williams2a1ef012025-03-03 11:09:20 -050077 required: false,
78 include_type: 'system',
79)
Ed Tanous26ed4a12022-07-13 13:46:08 -070080if not boost.found()
Brad Bishope833e0b2025-07-15 09:51:44 -040081 cmake = import('cmake')
82 opt = cmake.subproject_options()
83 boost_libs = ['asio', 'callable_traits']
Brad Bishop9014d222025-07-15 16:16:35 -040084 opt.add_cmake_defines(
85 {
86 'CMAKE_CXX_FLAGS': ' '.join(boost_flags),
87 'CMAKE_C_FLAGS': ' '.join(boost_flags),
88 'BOOST_INCLUDE_LIBRARIES': ';'.join(boost_libs),
89 },
90 )
Brad Bishope833e0b2025-07-15 09:51:44 -040091
92 boost_deps = []
93 boost_proj = cmake.subproject('boost', required: true, options: opt)
94 foreach boost_lib : boost_libs
95 boost_lib_instance = boost_proj.dependency('boost_' + boost_lib).as_system()
96 boost_deps += [boost_lib_instance]
97 endforeach
98 boost = declare_dependency(dependencies: boost_deps)
Ed Tanous26ed4a12022-07-13 13:46:08 -070099endif
Brad Bishopd6aa5522022-05-31 19:23:48 -0400100
Patrick Williamsec874072023-11-29 06:45:19 -0600101if get_option('tests').allowed()
Brad Bishopf3fe0db2025-07-09 16:33:11 -0400102 gtest = dependency(
103 'gtest_main',
104 main: true,
105 version: '>=1.15.2',
106 required: true,
107 )
108 gmock = dependency('gmock', required: true)
Brad Bishop0aa15902019-05-08 21:30:01 -0400109 subdir('src/test')
110 subdir('libmapper/test')
111endif
112
Brad Bishop0aa15902019-05-08 21:30:01 -0400113install_headers('libmapper/mapper.h')
114
115libmapper = library(
116 'mapper',
117 'libmapper/mapper.c',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500118 dependencies: [dependency('libsystemd')],
Brad Bishop0aa15902019-05-08 21:30:01 -0400119 gnu_symbol_visibility: 'hidden',
120 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -0500121 install: true,
122)
Brad Bishop0aa15902019-05-08 21:30:01 -0400123
Patrick Williamsd4887752022-06-16 11:29:08 -0500124mapper_dep = declare_dependency(
125 link_with: libmapper,
126 include_directories: include_directories('libmapper'),
Patrick Williams2a1ef012025-03-03 11:09:20 -0500127 dependencies: [dependency('libsystemd')],
Patrick Williamsd4887752022-06-16 11:29:08 -0500128)
129
Brad Bishop0aa15902019-05-08 21:30:01 -0400130import('pkgconfig').generate(
131 name: 'libmapper',
132 description: 'OpenBMC service discovery utility library',
133 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -0500134 libraries: libmapper,
135)
Brad Bishop0aa15902019-05-08 21:30:01 -0400136
137executable(
138 'mapper',
139 'libmapper/app.c',
140 link_with: libmapper,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500141 dependencies: [dependency('libsystemd')],
142 install: true,
143)
Brad Bishop0aa15902019-05-08 21:30:01 -0400144
Andrew Jefferyfb853662024-05-03 14:54:11 +0930145mapperx = executable(
Brad Bishop0aa15902019-05-08 21:30:01 -0400146 'mapperx',
147 [
148 'src/main.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400149 'src/processing.cpp',
150 'src/associations.cpp',
Willy Tuaba14d32023-01-31 14:19:59 -0800151 'src/handler.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400152 ],
153 dependencies: [
Ed Tanous26ed4a12022-07-13 13:46:08 -0700154 boost,
Brad Bishop0aa15902019-05-08 21:30:01 -0400155 dependency('libsystemd'),
Brad Bishop5962db52022-05-16 21:04:05 -0400156 phosphor_dbus_interfaces,
Brad Bishop0aa15902019-05-08 21:30:01 -0400157 sdbusplus,
Brad Bishop0aa15902019-05-08 21:30:01 -0400158 dependency('threads'),
Konstantin Aladyshev883d91d2024-04-03 12:38:37 +0300159 dependency('tinyxml2', default_options: ['tests=false']),
Brad Bishop0aa15902019-05-08 21:30:01 -0400160 ],
Brad Bishop13cf45f2025-07-14 16:35:13 -0400161 implicit_include_directories: false,
Brad Bishop2ec91572022-06-03 08:52:11 -0400162 install: true,
163 install_dir: join_paths(
Patrick Williams2a1ef012025-03-03 11:09:20 -0500164 get_option('prefix'),
165 get_option('libexecdir'),
166 meson.project_name(),
167 ),
Brad Bishop0aa15902019-05-08 21:30:01 -0400168)
Andrew Jefferyfb853662024-05-03 14:54:11 +0930169meson.override_find_program('mapperx', mapperx)
Brad Bishop0aa15902019-05-08 21:30:01 -0400170
Brad Bishop2ec91572022-06-03 08:52:11 -0400171systemd_system_unit_dir = dependency('systemd').get_variable(
Patrick Williamsfcae5262025-07-09 11:27:59 -0400172 'systemd_system_unit_dir',
Brad Bishop2ec91572022-06-03 08:52:11 -0400173)
174
175conf = configuration_data()
176conf.set('BINDIR', join_paths(get_option('prefix'), get_option('bindir')))
Patrick Williams2a1ef012025-03-03 11:09:20 -0500177conf.set(
178 'LIBEXECDIR',
179 join_paths(get_option('prefix'), get_option('libexecdir')),
180)
Brad Bishop2ec91572022-06-03 08:52:11 -0400181
182unit_files = [
183 'xyz.openbmc_project.ObjectMapper.service',
184 'mapper-subtree-remove@.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500185 'mapper-wait@.service',
Brad Bishop2ec91572022-06-03 08:52:11 -0400186]
187
188foreach u : unit_files
189 configure_file(
190 configuration: conf,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500191 input: join_paths('src/systemd', u) + '.in',
192 install: true,
Brad Bishop2ec91572022-06-03 08:52:11 -0400193 install_dir: systemd_system_unit_dir,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500194 output: u,
Brad Bishop2ec91572022-06-03 08:52:11 -0400195 )
196endforeach
197
198dbus_system_bus_services_dir = dependency('dbus-1').get_variable(
Patrick Williams40302742023-04-12 08:01:37 -0500199 'system_bus_services_dir',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500200 pkgconfig_define: ['prefix', get_option('prefix')],
Brad Bishop2ec91572022-06-03 08:52:11 -0400201)
202
203install_data(
204 'src/dbus/xyz.openbmc_project.ObjectMapper.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500205 install_dir: dbus_system_bus_services_dir,
206)
Brad Bishop2ec91572022-06-03 08:52:11 -0400207
208install_data(
209 'src/dbus/xyz.openbmc_project.ObjectMapper.conf',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500210 install_dir: get_option('datadir') / 'dbus-1' / 'system.d',
211)
Brad Bishop2ec91572022-06-03 08:52:11 -0400212
Brad Bishop42e5aee2023-02-03 13:57:33 -0500213if not get_option('unit-failure-monitor').disabled()
214 executable(
215 'phosphor-unit-failure-monitor',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500216 ['fail-monitor/main.cpp', 'fail-monitor/monitor.cpp'],
Brad Bishop0426f312025-07-14 16:23:53 -0400217 dependencies: [cli11, phosphor_logging, sdbusplus],
Brad Bishop13cf45f2025-07-14 16:35:13 -0400218 implicit_include_directories: false,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500219 install: true,
Brad Bishop42e5aee2023-02-03 13:57:33 -0500220 )
221endif