blob: 8b2f7a5989eb7d25f0ee3bfa2ef0da6bbd6deae9 [file] [log] [blame]
Brad Bishop0aa15902019-05-08 21:30:01 -04001project(
2 'phosphor-objmgr',
3 'c', 'cpp',
4 default_options: [
Brad Bishopd6aa5522022-05-31 19:23:48 -04005 'buildtype=debugoptimized',
Patrick Williams26ed9802023-07-12 11:16:09 -05006 'cpp_std=c++23',
Brad Bishop0aa15902019-05-08 21:30:01 -04007 'warning_level=3',
8 'werror=true',
9 ],
10 license: 'Apache-2.0',
Patrick Williams26ed9802023-07-12 11:16:09 -050011 meson_version: '>=1.1.1',
Brad Bishop0aa15902019-05-08 21:30:01 -040012 version: '1.0',
13)
14
Brad Bishop8c243622022-07-11 11:21:50 -040015cxx = meson.get_compiler('cpp')
16
17if cxx.has_header('CLI/CLI.hpp')
18 cli11_dep = declare_dependency()
19else
20 cli11_dep = dependency('cli11')
21endif
Patrick Williamsf814e5b2022-03-21 11:14:17 -050022phosphor_logging = dependency('phosphor-logging')
Brad Bishop5962db52022-05-16 21:04:05 -040023phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
Patrick Williamsf814e5b2022-03-21 11:14:17 -050024sdbusplus = dependency('sdbusplus')
Ed Tanous26ed4a12022-07-13 13:46:08 -070025boost = dependency('boost', version : '>=1.79.0', required: false, include_type: 'system')
26if not boost.found()
27 subproject('boost', required: false)
28 boost_inc = include_directories('subprojects/boost_1_79_0/', is_system:true)
29 boost = declare_dependency(include_directories : boost_inc)
30 boost = boost.as_system('system')
31endif
Ed Tanous41ad8382025-02-13 17:00:14 -080032add_project_arguments(
33 [
34 '-DBOOST_ASIO_DISABLE_THREADS',
35 '-DBOOST_ASIO_NO_DEPRECATED',
36 ],
37 language: 'cpp',
38)
Brad Bishopd6aa5522022-05-31 19:23:48 -040039
40if get_option('buildtype').startswith('debug')
41 add_project_arguments('-DMAPPER_ENABLE_DEBUG', language : 'cpp')
42endif
43
Patrick Williamsec874072023-11-29 06:45:19 -060044if get_option('tests').allowed()
Brad Bishop0aa15902019-05-08 21:30:01 -040045 gtest = dependency('gtest', main: true, disabler: true, required: false)
46 gmock = dependency('gmock', disabler: true, required: false)
47 if not gtest.found() or not gmock.found()
48 gtest_proj = import('cmake').subproject('googletest', required: false)
49 if gtest_proj.found()
50 gtest = declare_dependency(
51 dependencies: [
52 dependency('threads'),
53 gtest_proj.dependency('gtest'),
54 gtest_proj.dependency('gtest_main'),
55 ]
56 )
57 gmock = gtest_proj.dependency('gmock')
58 else
59 assert(
Patrick Williamsec874072023-11-29 06:45:19 -060060 not get_option('tests').allowed(),
Brad Bishop0aa15902019-05-08 21:30:01 -040061 'Googletest is required if tests are enabled'
62 )
63 endif
64 endif
65 subdir('src/test')
66 subdir('libmapper/test')
67endif
68
Brad Bishop0aa15902019-05-08 21:30:01 -040069install_headers('libmapper/mapper.h')
70
71libmapper = library(
72 'mapper',
73 'libmapper/mapper.c',
74 dependencies: [ dependency('libsystemd') ],
75 gnu_symbol_visibility: 'hidden',
76 version: meson.project_version(),
77 install: true)
78
Patrick Williamsd4887752022-06-16 11:29:08 -050079mapper_dep = declare_dependency(
80 link_with: libmapper,
81 include_directories: include_directories('libmapper'),
82 dependencies: [ dependency('libsystemd') ],
83)
84
Brad Bishop0aa15902019-05-08 21:30:01 -040085import('pkgconfig').generate(
86 name: 'libmapper',
87 description: 'OpenBMC service discovery utility library',
88 version: meson.project_version(),
89 libraries: libmapper)
90
91executable(
92 'mapper',
93 'libmapper/app.c',
94 link_with: libmapper,
95 dependencies: [ dependency('libsystemd') ],
96 install: true)
97
Andrew Jefferyfb853662024-05-03 14:54:11 +093098mapperx = executable(
Brad Bishop0aa15902019-05-08 21:30:01 -040099 'mapperx',
100 [
101 'src/main.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400102 'src/processing.cpp',
103 'src/associations.cpp',
Willy Tuaba14d32023-01-31 14:19:59 -0800104 'src/handler.cpp',
Brad Bishop0aa15902019-05-08 21:30:01 -0400105 ],
106 dependencies: [
Ed Tanous26ed4a12022-07-13 13:46:08 -0700107 boost,
Brad Bishop0aa15902019-05-08 21:30:01 -0400108 dependency('libsystemd'),
Brad Bishop5962db52022-05-16 21:04:05 -0400109 phosphor_dbus_interfaces,
Brad Bishop0aa15902019-05-08 21:30:01 -0400110 phosphor_logging,
111 sdbusplus,
Brad Bishop0aa15902019-05-08 21:30:01 -0400112 dependency('threads'),
Konstantin Aladyshev883d91d2024-04-03 12:38:37 +0300113 dependency('tinyxml2', default_options: ['tests=false']),
Brad Bishop0aa15902019-05-08 21:30:01 -0400114 ],
Brad Bishop2ec91572022-06-03 08:52:11 -0400115 install: true,
116 install_dir: join_paths(
117 get_option('prefix'), get_option('libexecdir'), meson.project_name())
Brad Bishop0aa15902019-05-08 21:30:01 -0400118)
Andrew Jefferyfb853662024-05-03 14:54:11 +0930119meson.override_find_program('mapperx', mapperx)
Brad Bishop0aa15902019-05-08 21:30:01 -0400120
Brad Bishop2ec91572022-06-03 08:52:11 -0400121systemd_system_unit_dir = dependency('systemd').get_variable(
Patrick Williams40302742023-04-12 08:01:37 -0500122 'systemdsystemunitdir'
Brad Bishop2ec91572022-06-03 08:52:11 -0400123)
124
125conf = configuration_data()
126conf.set('BINDIR', join_paths(get_option('prefix'), get_option('bindir')))
127conf.set('LIBEXECDIR', join_paths(
128 get_option('prefix'), get_option('libexecdir')))
129
130unit_files = [
131 'xyz.openbmc_project.ObjectMapper.service',
132 'mapper-subtree-remove@.service',
133 'mapper-wait@.service'
134]
135
136foreach u : unit_files
137 configure_file(
138 configuration: conf,
139 input : join_paths('src/systemd', u) + '.in',
140 install : true,
141 install_dir: systemd_system_unit_dir,
142 output : u
143 )
144endforeach
145
146dbus_system_bus_services_dir = dependency('dbus-1').get_variable(
Patrick Williams40302742023-04-12 08:01:37 -0500147 'system_bus_services_dir',
Brad Bishop2ec91572022-06-03 08:52:11 -0400148 pkgconfig_define: ['prefix', get_option('prefix')]
149)
150
151install_data(
152 'src/dbus/xyz.openbmc_project.ObjectMapper.service',
153 install_dir: dbus_system_bus_services_dir)
154
155install_data(
156 'src/dbus/xyz.openbmc_project.ObjectMapper.conf',
157 install_dir: get_option('datadir') / 'dbus-1' / 'system.d')
158
Brad Bishop42e5aee2023-02-03 13:57:33 -0500159if not get_option('unit-failure-monitor').disabled()
160 executable(
161 'phosphor-unit-failure-monitor',
162 [
163 'fail-monitor/main.cpp',
164 'fail-monitor/monitor.cpp',
165 ],
166 dependencies: [
167 cli11_dep,
168 phosphor_logging,
169 ],
170 install: true
171 )
172endif