blob: c5d05e3685672a83299d648bb931c2e43d78290c [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 Bishop8c243622022-07-11 11:21:50 -040016cxx = meson.get_compiler('cpp')
17
18if cxx.has_header('CLI/CLI.hpp')
19 cli11_dep = declare_dependency()
20else
21 cli11_dep = dependency('cli11')
22endif
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',
28 version: '>=1.79.0',
29 required: false,
30 include_type: 'system',
31)
Ed Tanous26ed4a12022-07-13 13:46:08 -070032if not boost.found()
Patrick Williams2a1ef012025-03-03 11:09:20 -050033 subproject('boost', required: false)
34 boost_inc = include_directories('subprojects/boost_1_79_0/', is_system: true)
35 boost = declare_dependency(include_directories: boost_inc)
36 boost = boost.as_system('system')
Ed Tanous26ed4a12022-07-13 13:46:08 -070037endif
Ed Tanous41ad8382025-02-13 17:00:14 -080038add_project_arguments(
Patrick Williams2a1ef012025-03-03 11:09:20 -050039 ['-DBOOST_ASIO_DISABLE_THREADS', '-DBOOST_ASIO_NO_DEPRECATED'],
Ed Tanous41ad8382025-02-13 17:00:14 -080040 language: 'cpp',
41)
Brad Bishopd6aa5522022-05-31 19:23:48 -040042
43if get_option('buildtype').startswith('debug')
Patrick Williams2a1ef012025-03-03 11:09:20 -050044 add_project_arguments('-DMAPPER_ENABLE_DEBUG', language: 'cpp')
Brad Bishopd6aa5522022-05-31 19:23:48 -040045endif
46
Patrick Williamsec874072023-11-29 06:45:19 -060047if get_option('tests').allowed()
Brad Bishop0aa15902019-05-08 21:30:01 -040048 gtest = dependency('gtest', main: true, disabler: true, required: false)
49 gmock = dependency('gmock', disabler: true, required: false)
50 if not gtest.found() or not gmock.found()
51 gtest_proj = import('cmake').subproject('googletest', required: false)
52 if gtest_proj.found()
53 gtest = declare_dependency(
54 dependencies: [
55 dependency('threads'),
56 gtest_proj.dependency('gtest'),
57 gtest_proj.dependency('gtest_main'),
Patrick Williams2a1ef012025-03-03 11:09:20 -050058 ],
Brad Bishop0aa15902019-05-08 21:30:01 -040059 )
60 gmock = gtest_proj.dependency('gmock')
61 else
62 assert(
Patrick Williamsec874072023-11-29 06:45:19 -060063 not get_option('tests').allowed(),
Patrick Williams2a1ef012025-03-03 11:09:20 -050064 'Googletest is required if tests are enabled',
Brad Bishop0aa15902019-05-08 21:30:01 -040065 )
66 endif
67 endif
68 subdir('src/test')
69 subdir('libmapper/test')
70endif
71
Brad Bishop0aa15902019-05-08 21:30:01 -040072install_headers('libmapper/mapper.h')
73
74libmapper = library(
75 'mapper',
76 'libmapper/mapper.c',
Patrick Williams2a1ef012025-03-03 11:09:20 -050077 dependencies: [dependency('libsystemd')],
Brad Bishop0aa15902019-05-08 21:30:01 -040078 gnu_symbol_visibility: 'hidden',
79 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -050080 install: true,
81)
Brad Bishop0aa15902019-05-08 21:30:01 -040082
Patrick Williamsd4887752022-06-16 11:29:08 -050083mapper_dep = declare_dependency(
84 link_with: libmapper,
85 include_directories: include_directories('libmapper'),
Patrick Williams2a1ef012025-03-03 11:09:20 -050086 dependencies: [dependency('libsystemd')],
Patrick Williamsd4887752022-06-16 11:29:08 -050087)
88
Brad Bishop0aa15902019-05-08 21:30:01 -040089import('pkgconfig').generate(
90 name: 'libmapper',
91 description: 'OpenBMC service discovery utility library',
92 version: meson.project_version(),
Patrick Williams2a1ef012025-03-03 11:09:20 -050093 libraries: libmapper,
94)
Brad Bishop0aa15902019-05-08 21:30:01 -040095
96executable(
97 'mapper',
98 'libmapper/app.c',
99 link_with: libmapper,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500100 dependencies: [dependency('libsystemd')],
101 install: true,
102)
Brad Bishop0aa15902019-05-08 21:30:01 -0400103
Andrew Jefferyfb853662024-05-03 14:54:11 +0930104mapperx = executable(
Brad Bishop0aa15902019-05-08 21:30:01 -0400105 'mapperx',
106 [
107 'src/main.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400108 'src/processing.cpp',
109 'src/associations.cpp',
Willy Tuaba14d32023-01-31 14:19:59 -0800110 'src/handler.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400111 ],
112 dependencies: [
Ed Tanous26ed4a12022-07-13 13:46:08 -0700113 boost,
Brad Bishop0aa15902019-05-08 21:30:01 -0400114 dependency('libsystemd'),
Brad Bishop5962db52022-05-16 21:04:05 -0400115 phosphor_dbus_interfaces,
Brad Bishop0aa15902019-05-08 21:30:01 -0400116 phosphor_logging,
117 sdbusplus,
Brad Bishop0aa15902019-05-08 21:30:01 -0400118 dependency('threads'),
Konstantin Aladyshev883d91d2024-04-03 12:38:37 +0300119 dependency('tinyxml2', default_options: ['tests=false']),
Brad Bishop0aa15902019-05-08 21:30:01 -0400120 ],
Brad Bishop2ec91572022-06-03 08:52:11 -0400121 install: true,
122 install_dir: join_paths(
Patrick Williams2a1ef012025-03-03 11:09:20 -0500123 get_option('prefix'),
124 get_option('libexecdir'),
125 meson.project_name(),
126 ),
Brad Bishop0aa15902019-05-08 21:30:01 -0400127)
Andrew Jefferyfb853662024-05-03 14:54:11 +0930128meson.override_find_program('mapperx', mapperx)
Brad Bishop0aa15902019-05-08 21:30:01 -0400129
Brad Bishop2ec91572022-06-03 08:52:11 -0400130systemd_system_unit_dir = dependency('systemd').get_variable(
Patrick Williams2a1ef012025-03-03 11:09:20 -0500131 'systemdsystemunitdir',
Brad Bishop2ec91572022-06-03 08:52:11 -0400132)
133
134conf = configuration_data()
135conf.set('BINDIR', join_paths(get_option('prefix'), get_option('bindir')))
Patrick Williams2a1ef012025-03-03 11:09:20 -0500136conf.set(
137 'LIBEXECDIR',
138 join_paths(get_option('prefix'), get_option('libexecdir')),
139)
Brad Bishop2ec91572022-06-03 08:52:11 -0400140
141unit_files = [
142 'xyz.openbmc_project.ObjectMapper.service',
143 'mapper-subtree-remove@.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500144 'mapper-wait@.service',
Brad Bishop2ec91572022-06-03 08:52:11 -0400145]
146
147foreach u : unit_files
148 configure_file(
149 configuration: conf,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500150 input: join_paths('src/systemd', u) + '.in',
151 install: true,
Brad Bishop2ec91572022-06-03 08:52:11 -0400152 install_dir: systemd_system_unit_dir,
Patrick Williams2a1ef012025-03-03 11:09:20 -0500153 output: u,
Brad Bishop2ec91572022-06-03 08:52:11 -0400154 )
155endforeach
156
157dbus_system_bus_services_dir = dependency('dbus-1').get_variable(
Patrick Williams40302742023-04-12 08:01:37 -0500158 'system_bus_services_dir',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500159 pkgconfig_define: ['prefix', get_option('prefix')],
Brad Bishop2ec91572022-06-03 08:52:11 -0400160)
161
162install_data(
163 'src/dbus/xyz.openbmc_project.ObjectMapper.service',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500164 install_dir: dbus_system_bus_services_dir,
165)
Brad Bishop2ec91572022-06-03 08:52:11 -0400166
167install_data(
168 'src/dbus/xyz.openbmc_project.ObjectMapper.conf',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500169 install_dir: get_option('datadir') / 'dbus-1' / 'system.d',
170)
Brad Bishop2ec91572022-06-03 08:52:11 -0400171
Brad Bishop42e5aee2023-02-03 13:57:33 -0500172if not get_option('unit-failure-monitor').disabled()
173 executable(
174 'phosphor-unit-failure-monitor',
Patrick Williams2a1ef012025-03-03 11:09:20 -0500175 ['fail-monitor/main.cpp', 'fail-monitor/monitor.cpp'],
176 dependencies: [cli11_dep, phosphor_logging],
177 install: true,
Brad Bishop42e5aee2023-02-03 13:57:33 -0500178 )
179endif