1project( 2 'Telemetry', 3 'cpp', 4 meson_version: '>=0.55.0', 5 default_options: [ 6 'buildtype=debugoptimized', 7 'cpp_std=c++17', 8 # TODO: Without RTTI telemetry does not build using Boost 1.74.0 9 # https://github.com/chriskohlhoff/asio/issues/533 10 #'cpp_rtti=false', 11 'warning_level=3', 12 'werror=true', 13 'b_lto=true', 14 ], 15 license: 'Apache-2.0', 16) 17 18cpp = meson.get_compiler('cpp') 19add_project_arguments( 20 cpp.get_supported_arguments([ 21 '-DBOOST_ASIO_DISABLE_THREADS', 22 '-DBOOST_ALL_NO_LIB', 23 '-DBOOST_SYSTEM_NO_DEPRECATED', 24 '-DBOOST_ASIO_NO_DEPRECATED', 25 '-DBOOST_NO_RTTI', 26 '-DBOOST_NO_TYPEID', 27 '-Wno-unused-parameter', 28 ]), 29 language: 'cpp' 30) 31 32boost = dependency('boost', version: '>=1.74.0', required: false) 33if not boost.found() 34 subproject('boost', required: false) 35 boost = declare_dependency(include_directories: 'subprojects/boost_1_74_0') 36endif 37 38phosphor_logging = dependency('phosphor-logging', required: false) 39if not phosphor_logging.found() 40 subproject('phosphor-logging', required: false) 41 phosphor_logging = declare_dependency( 42 include_directories: 'subprojects/phosphor-logging' 43 ) 44endif 45 46sdbusplus = dependency('sdbusplus',required : false) 47if not sdbusplus.found() 48 sdbusplus_proj = subproject('sdbusplus', required: true) 49 sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') 50endif 51 52systemd = dependency('systemd') 53 54if cpp.has_header('nlohmann/json.hpp') 55 nlohmann_json = declare_dependency() 56else 57 subproject('nlohmann', required: false) 58 nlohmann_json = declare_dependency( 59 include_directories: [ 60 'subprojects/nlohmann/single_include', 61 'subprojects/nlohmann/single_include/nlohmann', 62 ] 63 ) 64endif 65 66executable( 67 'telemetry', 68 [ 69 'src/main.cpp', 70 'src/persistent_json_storage.cpp', 71 'src/report.cpp', 72 'src/report_manager.cpp', 73 'src/sensor_cache.cpp', 74 ], 75 dependencies: [ 76 boost, 77 nlohmann_json, 78 sdbusplus, 79 phosphor_logging, 80 ], 81 include_directories: 'src', 82 install: true, 83 install_dir: get_option('prefix') / get_option('bindir'), 84 pie: true, 85) 86 87configure_file( 88 input: 'xyz.openbmc_project.Telemetry.service.in', 89 output: 'xyz.openbmc_project.Telemetry.service', 90 configuration: { 91 'bindir': get_option('prefix') / get_option('bindir'), 92 }, 93 install: true, 94 install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir'), 95) 96 97if get_option('buildtest') 98 subdir('tests') 99endif 100