xref: /openbmc/telemetry/meson.build (revision c8e3a64a)
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
32b5645947SKrzysztof Grobelnyboost = dependency(
33b5645947SKrzysztof Grobelny  'boost',
34b5645947SKrzysztof Grobelny  version: '>=1.74.0',
35b5645947SKrzysztof Grobelny  required: false,
36b5645947SKrzysztof Grobelny  modules: ['coroutine'])
37b5645947SKrzysztof Grobelny
3864b75a5bSKrzysztof Grobelnyif not boost.found()
3964b75a5bSKrzysztof Grobelny    subproject('boost', required: false)
40a4bf740cSWludzik, Jozef    boost  = declare_dependency(include_directories: 'subprojects/boost_1_74_0')
4164b75a5bSKrzysztof Grobelnyendif
4264b75a5bSKrzysztof Grobelny
4364b75a5bSKrzysztof Grobelnyphosphor_logging = dependency('phosphor-logging', required: false)
4464b75a5bSKrzysztof Grobelnyif not phosphor_logging.found()
4564b75a5bSKrzysztof Grobelny    subproject('phosphor-logging', required: false)
4664b75a5bSKrzysztof Grobelny    phosphor_logging = declare_dependency(
4764b75a5bSKrzysztof Grobelny        include_directories: 'subprojects/phosphor-logging'
4864b75a5bSKrzysztof Grobelny    )
4964b75a5bSKrzysztof Grobelnyendif
5064b75a5bSKrzysztof Grobelny
5164b75a5bSKrzysztof Grobelnysdbusplus = dependency('sdbusplus',required : false)
5264b75a5bSKrzysztof Grobelnyif not sdbusplus.found()
5364b75a5bSKrzysztof Grobelny  sdbusplus_proj = subproject('sdbusplus', required: true)
5464b75a5bSKrzysztof Grobelny  sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
5564b75a5bSKrzysztof Grobelnyendif
5664b75a5bSKrzysztof Grobelny
5764b75a5bSKrzysztof Grobelnysystemd = dependency('systemd')
5864b75a5bSKrzysztof Grobelny
5973da6906SKrzysztof Grobelnyif cpp.has_header('nlohmann/json.hpp')
6073da6906SKrzysztof Grobelny    nlohmann_json = declare_dependency()
6173da6906SKrzysztof Grobelnyelse
6273da6906SKrzysztof Grobelny    subproject('nlohmann', required: false)
6373da6906SKrzysztof Grobelny    nlohmann_json = declare_dependency(
6473da6906SKrzysztof Grobelny        include_directories: [
6573da6906SKrzysztof Grobelny            'subprojects/nlohmann/single_include',
6673da6906SKrzysztof Grobelny            'subprojects/nlohmann/single_include/nlohmann',
6773da6906SKrzysztof Grobelny        ]
6873da6906SKrzysztof Grobelny    )
6973da6906SKrzysztof Grobelnyendif
7073da6906SKrzysztof Grobelny
7164b75a5bSKrzysztof Grobelnyexecutable(
7264b75a5bSKrzysztof Grobelny    'telemetry',
7364b75a5bSKrzysztof Grobelny    [
7464b75a5bSKrzysztof Grobelny        'src/main.cpp',
75*c8e3a64aSKrzysztof Grobelny        'src/metric.cpp',
767f06f613SKrzysztof Grobelny        'src/persistent_json_storage.cpp',
77cb88cfdfSWludzik, Jozef        'src/report.cpp',
782f9f9b87SWludzik, Jozef        'src/report_factory.cpp',
7964b75a5bSKrzysztof Grobelny        'src/report_manager.cpp',
80b5645947SKrzysztof Grobelny        'src/sensor.cpp',
817f06f613SKrzysztof Grobelny        'src/sensor_cache.cpp',
8264b75a5bSKrzysztof Grobelny    ],
8364b75a5bSKrzysztof Grobelny    dependencies: [
8464b75a5bSKrzysztof Grobelny        boost,
8573da6906SKrzysztof Grobelny        nlohmann_json,
8664b75a5bSKrzysztof Grobelny        sdbusplus,
8764b75a5bSKrzysztof Grobelny        phosphor_logging,
8864b75a5bSKrzysztof Grobelny    ],
8964b75a5bSKrzysztof Grobelny    include_directories: 'src',
9064b75a5bSKrzysztof Grobelny    install: true,
9164b75a5bSKrzysztof Grobelny    install_dir: get_option('prefix') / get_option('bindir'),
9264b75a5bSKrzysztof Grobelny    pie: true,
9364b75a5bSKrzysztof Grobelny)
9464b75a5bSKrzysztof Grobelny
9564b75a5bSKrzysztof Grobelnyconfigure_file(
9664b75a5bSKrzysztof Grobelny    input: 'xyz.openbmc_project.Telemetry.service.in',
9764b75a5bSKrzysztof Grobelny    output: 'xyz.openbmc_project.Telemetry.service',
9864b75a5bSKrzysztof Grobelny    configuration: {
9964b75a5bSKrzysztof Grobelny        'bindir': get_option('prefix') / get_option('bindir'),
10064b75a5bSKrzysztof Grobelny    },
10164b75a5bSKrzysztof Grobelny    install: true,
10264b75a5bSKrzysztof Grobelny    install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir'),
10364b75a5bSKrzysztof Grobelny)
10473da6906SKrzysztof Grobelny
10573da6906SKrzysztof Grobelnyif get_option('buildtest')
10673da6906SKrzysztof Grobelny    subdir('tests')
10773da6906SKrzysztof Grobelnyendif
108