xref: /openbmc/telemetry/meson.build (revision 7f06f613)
164b75a5bSKrzysztof Grobelnyproject(
264b75a5bSKrzysztof Grobelny    'Telemetry',
364b75a5bSKrzysztof Grobelny    'cpp',
464b75a5bSKrzysztof Grobelny    meson_version: '>=0.55.0',
564b75a5bSKrzysztof Grobelny    default_options: [
664b75a5bSKrzysztof Grobelny        'buildtype=debugoptimized',
764b75a5bSKrzysztof Grobelny        'cpp_std=c++17',
8a4bf740cSWludzik, Jozef        # TODO: Without RTTI telemetry does not build using Boost 1.74.0
9a4bf740cSWludzik, Jozef        # https://github.com/chriskohlhoff/asio/issues/533
10a4bf740cSWludzik, Jozef        #'cpp_rtti=false',
1164b75a5bSKrzysztof Grobelny        'warning_level=3',
1264b75a5bSKrzysztof Grobelny        'werror=true',
1364b75a5bSKrzysztof Grobelny        'b_lto=true',
1464b75a5bSKrzysztof Grobelny    ],
1564b75a5bSKrzysztof Grobelny    license: 'Apache-2.0',
1664b75a5bSKrzysztof Grobelny)
1764b75a5bSKrzysztof Grobelny
1864b75a5bSKrzysztof Grobelnycpp = meson.get_compiler('cpp')
1964b75a5bSKrzysztof Grobelnyadd_project_arguments(
2064b75a5bSKrzysztof Grobelny    cpp.get_supported_arguments([
2164b75a5bSKrzysztof Grobelny        '-DBOOST_ASIO_DISABLE_THREADS',
2264b75a5bSKrzysztof Grobelny        '-DBOOST_ALL_NO_LIB',
2364b75a5bSKrzysztof Grobelny        '-DBOOST_SYSTEM_NO_DEPRECATED',
2464b75a5bSKrzysztof Grobelny        '-DBOOST_ASIO_NO_DEPRECATED',
2564b75a5bSKrzysztof Grobelny        '-DBOOST_NO_RTTI',
2664b75a5bSKrzysztof Grobelny        '-DBOOST_NO_TYPEID',
2764b75a5bSKrzysztof Grobelny        '-Wno-unused-parameter',
2864b75a5bSKrzysztof Grobelny    ]),
2964b75a5bSKrzysztof Grobelny    language: 'cpp'
3064b75a5bSKrzysztof Grobelny)
3164b75a5bSKrzysztof Grobelny
32a4bf740cSWludzik, Jozefboost = dependency('boost', version: '>=1.74.0', required: false)
3364b75a5bSKrzysztof Grobelnyif not boost.found()
3464b75a5bSKrzysztof Grobelny    subproject('boost', required: false)
35a4bf740cSWludzik, Jozef    boost  = declare_dependency(include_directories: 'subprojects/boost_1_74_0')
3664b75a5bSKrzysztof Grobelnyendif
3764b75a5bSKrzysztof Grobelny
3864b75a5bSKrzysztof Grobelnyphosphor_logging = dependency('phosphor-logging', required: false)
3964b75a5bSKrzysztof Grobelnyif not phosphor_logging.found()
4064b75a5bSKrzysztof Grobelny    subproject('phosphor-logging', required: false)
4164b75a5bSKrzysztof Grobelny    phosphor_logging = declare_dependency(
4264b75a5bSKrzysztof Grobelny        include_directories: 'subprojects/phosphor-logging'
4364b75a5bSKrzysztof Grobelny    )
4464b75a5bSKrzysztof Grobelnyendif
4564b75a5bSKrzysztof Grobelny
4664b75a5bSKrzysztof Grobelnysdbusplus = dependency('sdbusplus',required : false)
4764b75a5bSKrzysztof Grobelnyif not sdbusplus.found()
4864b75a5bSKrzysztof Grobelny  sdbusplus_proj = subproject('sdbusplus', required: true)
4964b75a5bSKrzysztof Grobelny  sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
5064b75a5bSKrzysztof Grobelnyendif
5164b75a5bSKrzysztof Grobelny
5264b75a5bSKrzysztof Grobelnysystemd = dependency('systemd')
5364b75a5bSKrzysztof Grobelny
5473da6906SKrzysztof Grobelnyif cpp.has_header('nlohmann/json.hpp')
5573da6906SKrzysztof Grobelny    nlohmann_json = declare_dependency()
5673da6906SKrzysztof Grobelnyelse
5773da6906SKrzysztof Grobelny    subproject('nlohmann', required: false)
5873da6906SKrzysztof Grobelny    nlohmann_json = declare_dependency(
5973da6906SKrzysztof Grobelny        include_directories: [
6073da6906SKrzysztof Grobelny            'subprojects/nlohmann/single_include',
6173da6906SKrzysztof Grobelny            'subprojects/nlohmann/single_include/nlohmann',
6273da6906SKrzysztof Grobelny        ]
6373da6906SKrzysztof Grobelny    )
6473da6906SKrzysztof Grobelnyendif
6573da6906SKrzysztof Grobelny
6664b75a5bSKrzysztof Grobelnyexecutable(
6764b75a5bSKrzysztof Grobelny    'telemetry',
6864b75a5bSKrzysztof Grobelny    [
6964b75a5bSKrzysztof Grobelny        'src/main.cpp',
70*7f06f613SKrzysztof Grobelny        'src/persistent_json_storage.cpp',
71cb88cfdfSWludzik, Jozef        'src/report.cpp',
7264b75a5bSKrzysztof Grobelny        'src/report_manager.cpp',
73*7f06f613SKrzysztof Grobelny        'src/sensor_cache.cpp',
7464b75a5bSKrzysztof Grobelny    ],
7564b75a5bSKrzysztof Grobelny    dependencies: [
7664b75a5bSKrzysztof Grobelny        boost,
7773da6906SKrzysztof Grobelny        nlohmann_json,
7864b75a5bSKrzysztof Grobelny        sdbusplus,
7964b75a5bSKrzysztof Grobelny        phosphor_logging,
8064b75a5bSKrzysztof Grobelny    ],
8164b75a5bSKrzysztof Grobelny    include_directories: 'src',
8264b75a5bSKrzysztof Grobelny    install: true,
8364b75a5bSKrzysztof Grobelny    install_dir: get_option('prefix') / get_option('bindir'),
8464b75a5bSKrzysztof Grobelny    pie: true,
8564b75a5bSKrzysztof Grobelny)
8664b75a5bSKrzysztof Grobelny
8764b75a5bSKrzysztof Grobelnyconfigure_file(
8864b75a5bSKrzysztof Grobelny    input: 'xyz.openbmc_project.Telemetry.service.in',
8964b75a5bSKrzysztof Grobelny    output: 'xyz.openbmc_project.Telemetry.service',
9064b75a5bSKrzysztof Grobelny    configuration: {
9164b75a5bSKrzysztof Grobelny        'bindir': get_option('prefix') / get_option('bindir'),
9264b75a5bSKrzysztof Grobelny    },
9364b75a5bSKrzysztof Grobelny    install: true,
9464b75a5bSKrzysztof Grobelny    install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir'),
9564b75a5bSKrzysztof Grobelny)
9673da6906SKrzysztof Grobelny
9773da6906SKrzysztof Grobelnyif get_option('buildtest')
9873da6906SKrzysztof Grobelny    subdir('tests')
9973da6906SKrzysztof Grobelnyendif
100