1project( 2 'phosphor-objmgr', 3 'c', 4 'cpp', 5 default_options: [ 6 'buildtype=debugoptimized', 7 'cpp_std=c++23', 8 'warning_level=3', 9 'werror=true', 10 ], 11 license: 'Apache-2.0', 12 meson_version: '>=1.1.1', 13 version: '1.0', 14) 15 16cxx = meson.get_compiler('cpp') 17 18if cxx.has_header('CLI/CLI.hpp') 19 cli11_dep = declare_dependency() 20else 21 cli11_dep = dependency('cli11') 22endif 23phosphor_logging = dependency('phosphor-logging') 24phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces') 25sdbusplus = dependency('sdbusplus') 26boost = dependency( 27 'boost', 28 version: '>=1.79.0', 29 required: false, 30 include_type: 'system', 31) 32if not boost.found() 33 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') 37endif 38add_project_arguments( 39 ['-DBOOST_ASIO_DISABLE_THREADS', '-DBOOST_ASIO_NO_DEPRECATED'], 40 language: 'cpp', 41) 42 43if get_option('buildtype').startswith('debug') 44 add_project_arguments('-DMAPPER_ENABLE_DEBUG', language: 'cpp') 45endif 46 47if get_option('tests').allowed() 48 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'), 58 ], 59 ) 60 gmock = gtest_proj.dependency('gmock') 61 else 62 assert( 63 not get_option('tests').allowed(), 64 'Googletest is required if tests are enabled', 65 ) 66 endif 67 endif 68 subdir('src/test') 69 subdir('libmapper/test') 70endif 71 72install_headers('libmapper/mapper.h') 73 74libmapper = library( 75 'mapper', 76 'libmapper/mapper.c', 77 dependencies: [dependency('libsystemd')], 78 gnu_symbol_visibility: 'hidden', 79 version: meson.project_version(), 80 install: true, 81) 82 83mapper_dep = declare_dependency( 84 link_with: libmapper, 85 include_directories: include_directories('libmapper'), 86 dependencies: [dependency('libsystemd')], 87) 88 89import('pkgconfig').generate( 90 name: 'libmapper', 91 description: 'OpenBMC service discovery utility library', 92 version: meson.project_version(), 93 libraries: libmapper, 94) 95 96executable( 97 'mapper', 98 'libmapper/app.c', 99 link_with: libmapper, 100 dependencies: [dependency('libsystemd')], 101 install: true, 102) 103 104mapperx = executable( 105 'mapperx', 106 [ 107 'src/main.cpp', 108 'src/processing.cpp', 109 'src/associations.cpp', 110 'src/handler.cpp', 111 ], 112 dependencies: [ 113 boost, 114 dependency('libsystemd'), 115 phosphor_dbus_interfaces, 116 phosphor_logging, 117 sdbusplus, 118 dependency('threads'), 119 dependency('tinyxml2', default_options: ['tests=false']), 120 ], 121 install: true, 122 install_dir: join_paths( 123 get_option('prefix'), 124 get_option('libexecdir'), 125 meson.project_name(), 126 ), 127) 128meson.override_find_program('mapperx', mapperx) 129 130systemd_system_unit_dir = dependency('systemd').get_variable( 131 'systemdsystemunitdir', 132) 133 134conf = configuration_data() 135conf.set('BINDIR', join_paths(get_option('prefix'), get_option('bindir'))) 136conf.set( 137 'LIBEXECDIR', 138 join_paths(get_option('prefix'), get_option('libexecdir')), 139) 140 141unit_files = [ 142 'xyz.openbmc_project.ObjectMapper.service', 143 'mapper-subtree-remove@.service', 144 'mapper-wait@.service', 145] 146 147foreach u : unit_files 148 configure_file( 149 configuration: conf, 150 input: join_paths('src/systemd', u) + '.in', 151 install: true, 152 install_dir: systemd_system_unit_dir, 153 output: u, 154 ) 155endforeach 156 157dbus_system_bus_services_dir = dependency('dbus-1').get_variable( 158 'system_bus_services_dir', 159 pkgconfig_define: ['prefix', get_option('prefix')], 160) 161 162install_data( 163 'src/dbus/xyz.openbmc_project.ObjectMapper.service', 164 install_dir: dbus_system_bus_services_dir, 165) 166 167install_data( 168 'src/dbus/xyz.openbmc_project.ObjectMapper.conf', 169 install_dir: get_option('datadir') / 'dbus-1' / 'system.d', 170) 171 172if not get_option('unit-failure-monitor').disabled() 173 executable( 174 'phosphor-unit-failure-monitor', 175 ['fail-monitor/main.cpp', 'fail-monitor/monitor.cpp'], 176 dependencies: [cli11_dep, phosphor_logging], 177 install: true, 178 ) 179endif 180