project( 'phosphor-objmgr', 'c', 'cpp', default_options: [ 'buildtype=debugoptimized', 'cpp_std=c++20', 'warning_level=3', 'werror=true', ], license: 'Apache-2.0', meson_version: '>=0.57.0', version: '1.0', ) cxx = meson.get_compiler('cpp') if cxx.has_header('CLI/CLI.hpp') cli11_dep = declare_dependency() else cli11_dep = dependency('cli11') endif phosphor_logging = dependency('phosphor-logging') phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces') sdbusplus = dependency('sdbusplus') boost = dependency('boost', version : '>=1.79.0', required: false, include_type: 'system') if not boost.found() subproject('boost', required: false) boost_inc = include_directories('subprojects/boost_1_79_0/', is_system:true) boost = declare_dependency(include_directories : boost_inc) boost = boost.as_system('system') endif if get_option('buildtype').startswith('debug') add_project_arguments('-DMAPPER_ENABLE_DEBUG', language : 'cpp') endif if get_option('tests').enabled() gtest = dependency('gtest', main: true, disabler: true, required: false) gmock = dependency('gmock', disabler: true, required: false) if not gtest.found() or not gmock.found() gtest_proj = import('cmake').subproject('googletest', required: false) if gtest_proj.found() gtest = declare_dependency( dependencies: [ dependency('threads'), gtest_proj.dependency('gtest'), gtest_proj.dependency('gtest_main'), ] ) gmock = gtest_proj.dependency('gmock') else assert( not get_option('tests').enabled(), 'Googletest is required if tests are enabled' ) endif endif subdir('src/test') subdir('libmapper/test') endif install_headers('libmapper/mapper.h') libmapper = library( 'mapper', 'libmapper/mapper.c', dependencies: [ dependency('libsystemd') ], gnu_symbol_visibility: 'hidden', version: meson.project_version(), install: true) mapper_dep = declare_dependency( link_with: libmapper, include_directories: include_directories('libmapper'), dependencies: [ dependency('libsystemd') ], ) import('pkgconfig').generate( name: 'libmapper', description: 'OpenBMC service discovery utility library', version: meson.project_version(), libraries: libmapper) executable( 'mapper', 'libmapper/app.c', link_with: libmapper, dependencies: [ dependency('libsystemd') ], install: true) executable( 'mapperx', [ 'src/main.cpp', 'src/processing.cpp', 'src/associations.cpp', 'src/handler.cpp', ], dependencies: [ boost, dependency('libsystemd'), phosphor_dbus_interfaces, phosphor_logging, sdbusplus, dependency('systemd'), dependency('threads'), dependency('tinyxml2'), ], install: true, install_dir: join_paths( get_option('prefix'), get_option('libexecdir'), meson.project_name()) ) systemd_system_unit_dir = dependency('systemd').get_variable( pkgconfig : 'systemdsystemunitdir' ) conf = configuration_data() conf.set('BINDIR', join_paths(get_option('prefix'), get_option('bindir'))) conf.set('LIBEXECDIR', join_paths( get_option('prefix'), get_option('libexecdir'))) unit_files = [ 'xyz.openbmc_project.ObjectMapper.service', 'mapper-subtree-remove@.service', 'mapper-wait@.service' ] foreach u : unit_files configure_file( configuration: conf, input : join_paths('src/systemd', u) + '.in', install : true, install_dir: systemd_system_unit_dir, output : u ) endforeach dbus_system_bus_services_dir = dependency('dbus-1').get_variable( pkgconfig: 'system_bus_services_dir', pkgconfig_define: ['prefix', get_option('prefix')] ) install_data( 'src/dbus/xyz.openbmc_project.ObjectMapper.service', install_dir: dbus_system_bus_services_dir) install_data( 'src/dbus/xyz.openbmc_project.ObjectMapper.conf', install_dir: get_option('datadir') / 'dbus-1' / 'system.d') if not get_option('unit-failure-monitor').disabled() executable( 'phosphor-unit-failure-monitor', [ 'fail-monitor/main.cpp', 'fail-monitor/monitor.cpp', ], dependencies: [ cli11_dep, phosphor_logging, ], install: true ) endif