project( 'phosphor-inventory-manager', 'cpp', version : '1.0.0', meson_version: '>=1.1.1', default_options: [ 'warning_level=3', 'werror=true', 'cpp_std=c++23', 'buildtype=debugoptimized', ] ) conf_data = configuration_data() conf_data.set_quoted('BUSNAME', 'xyz.openbmc_project.Inventory.Manager') conf_data.set_quoted('INVENTORY_ROOT', '/xyz/openbmc_project/inventory') conf_data.set_quoted('IFACE', 'xyz.openbmc_project.Inventory.Manager') conf_data.set_quoted('PIM_PERSIST_PATH', '/var/lib/phosphor-inventory-manager') conf_data.set_quoted('ASSOCIATIONS_FILE_PATH', '/usr/share/phosphor-inventory-manager/associations.json') conf_data.set('CLASS_VERSION', 2) conf_data.set('CREATE_ASSOCIATIONS', get_option('associations').allowed()) configure_file(output: 'config.h', configuration: conf_data ) cpp = meson.get_compiler('cpp') # Get Cereal dependency. cereal_dep = dependency('cereal', required: false) has_cereal = cpp.has_header_symbol( 'cereal/cereal.hpp', 'cereal::specialize', dependencies: cereal_dep, required: false) if not has_cereal cereal_opts = import('cmake').subproject_options() cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'}) cereal_proj = import('cmake').subproject( 'cereal', options: cereal_opts, required: false) assert(cereal_proj.found(), 'cereal is required') cereal_dep = cereal_proj.dependency('cereal') endif sdbusplus_dep = dependency('sdbusplus', required : false) phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') phosphor_logging_dep = dependency('phosphor-logging') prog_python = find_program('python3', required: true) sources = [] deps = [] if get_option('associations').allowed() sources += [ 'association_manager.cpp', ] nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') deps += [ nlohmann_json_dep, ] endif ifacesdir = get_option('IFACES_PATH') if ifacesdir == '' ifacesdir = phosphor_dbus_interfaces_dep.get_variable('yamldir') endif sdbusplus_python_env = {} if not sdbusplus_dep.found() sdbusplus_proj = subproject('sdbusplus') sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep') sdbusplus_python_env = {'PYTHONPATH': meson.current_source_dir() / 'subprojects' / 'sdbusplus' / 'tools'} endif generated_cpp = custom_target( 'generated.cpp', command : [ prog_python, meson.project_source_root() + '/pimgen.py', '-i', ifacesdir, '-d', get_option('YAML_PATH'), '-o', meson.current_build_dir(), '-b', conf_data.get_unquoted('BUSNAME'), 'generate-cpp' ], env: sdbusplus_python_env, output : 'generated.cpp') gen_serialization_hpp = custom_target( 'gen_serialization.hpp', command : [ prog_python, meson.project_source_root() + '/pimgen.py', '-i', ifacesdir, '-d', get_option('YAML_PATH'), '-o', meson.current_build_dir(), '-b', conf_data.get_unquoted('BUSNAME'), 'generate-serialization' ], env: sdbusplus_python_env, output : 'gen_serialization.hpp') sources += [ generated_cpp, gen_serialization_hpp, 'app.cpp', 'errors.cpp', 'functor.cpp', 'manager.cpp', ] deps += [ cereal_dep, phosphor_dbus_interfaces_dep, phosphor_logging_dep, sdbusplus_dep, ] executable( 'phosphor-inventory', sources, implicit_include_directories: true, dependencies: deps, install: true, install_dir: get_option('bindir'), ) build_tests = get_option('tests') if not build_tests.disabled() subdir('test') endif