xref: /openbmc/telemetry/meson.build (revision 73da6906)
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',
864b75a5bSKrzysztof Grobelny        'cpp_rtti=false',
964b75a5bSKrzysztof Grobelny        'warning_level=3',
1064b75a5bSKrzysztof Grobelny        'werror=true',
1164b75a5bSKrzysztof Grobelny        'b_lto=true',
1264b75a5bSKrzysztof Grobelny    ],
1364b75a5bSKrzysztof Grobelny    license: 'Apache-2.0',
1464b75a5bSKrzysztof Grobelny)
1564b75a5bSKrzysztof Grobelny
1664b75a5bSKrzysztof Grobelnycpp = meson.get_compiler('cpp')
1764b75a5bSKrzysztof Grobelnyadd_project_arguments(
1864b75a5bSKrzysztof Grobelny    cpp.get_supported_arguments([
1964b75a5bSKrzysztof Grobelny        '-DBOOST_ASIO_DISABLE_THREADS',
2064b75a5bSKrzysztof Grobelny        '-DBOOST_ALL_NO_LIB',
2164b75a5bSKrzysztof Grobelny        '-DBOOST_SYSTEM_NO_DEPRECATED',
2264b75a5bSKrzysztof Grobelny        '-DBOOST_ASIO_NO_DEPRECATED',
2364b75a5bSKrzysztof Grobelny        '-DBOOST_NO_RTTI',
2464b75a5bSKrzysztof Grobelny        '-DBOOST_NO_TYPEID',
2564b75a5bSKrzysztof Grobelny        '-Wno-unused-parameter',
2664b75a5bSKrzysztof Grobelny    ]),
2764b75a5bSKrzysztof Grobelny    language: 'cpp'
2864b75a5bSKrzysztof Grobelny)
2964b75a5bSKrzysztof Grobelny
3064b75a5bSKrzysztof Grobelnyboost = dependency('boost', version: '>=1.73.0', required: false)
3164b75a5bSKrzysztof Grobelnyif not boost.found()
3264b75a5bSKrzysztof Grobelny    subproject('boost', required: false)
3364b75a5bSKrzysztof Grobelny    boost  = declare_dependency(include_directories: 'subprojects/boost_1_73_0')
3464b75a5bSKrzysztof Grobelnyendif
3564b75a5bSKrzysztof Grobelny
3664b75a5bSKrzysztof Grobelnyphosphor_logging = dependency('phosphor-logging', required: false)
3764b75a5bSKrzysztof Grobelnyif not phosphor_logging.found()
3864b75a5bSKrzysztof Grobelny    subproject('phosphor-logging', required: false)
3964b75a5bSKrzysztof Grobelny    phosphor_logging = declare_dependency(
4064b75a5bSKrzysztof Grobelny        include_directories: 'subprojects/phosphor-logging'
4164b75a5bSKrzysztof Grobelny    )
4264b75a5bSKrzysztof Grobelnyendif
4364b75a5bSKrzysztof Grobelny
4464b75a5bSKrzysztof Grobelnysdbusplus = dependency('sdbusplus',required : false)
4564b75a5bSKrzysztof Grobelnyif not sdbusplus.found()
4664b75a5bSKrzysztof Grobelny  sdbusplus_proj = subproject('sdbusplus', required: true)
4764b75a5bSKrzysztof Grobelny  sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
4864b75a5bSKrzysztof Grobelnyendif
4964b75a5bSKrzysztof Grobelny
5064b75a5bSKrzysztof Grobelnysystemd = dependency('systemd')
5164b75a5bSKrzysztof Grobelny
52*73da6906SKrzysztof Grobelnyif cpp.has_header('nlohmann/json.hpp')
53*73da6906SKrzysztof Grobelny    nlohmann_json = declare_dependency()
54*73da6906SKrzysztof Grobelnyelse
55*73da6906SKrzysztof Grobelny    subproject('nlohmann', required: false)
56*73da6906SKrzysztof Grobelny    nlohmann_json = declare_dependency(
57*73da6906SKrzysztof Grobelny        include_directories: [
58*73da6906SKrzysztof Grobelny            'subprojects/nlohmann/single_include',
59*73da6906SKrzysztof Grobelny            'subprojects/nlohmann/single_include/nlohmann',
60*73da6906SKrzysztof Grobelny        ]
61*73da6906SKrzysztof Grobelny    )
62*73da6906SKrzysztof Grobelnyendif
63*73da6906SKrzysztof Grobelny
6464b75a5bSKrzysztof Grobelnyexecutable(
6564b75a5bSKrzysztof Grobelny    'telemetry',
6664b75a5bSKrzysztof Grobelny    [
6764b75a5bSKrzysztof Grobelny        'src/main.cpp',
68cb88cfdfSWludzik, Jozef        'src/report.cpp',
6964b75a5bSKrzysztof Grobelny        'src/report_manager.cpp',
70*73da6906SKrzysztof Grobelny        'src/persistent_json_storage.cpp',
7164b75a5bSKrzysztof Grobelny    ],
7264b75a5bSKrzysztof Grobelny    dependencies: [
7364b75a5bSKrzysztof Grobelny        boost,
74*73da6906SKrzysztof Grobelny        nlohmann_json,
7564b75a5bSKrzysztof Grobelny        sdbusplus,
7664b75a5bSKrzysztof Grobelny        phosphor_logging,
7764b75a5bSKrzysztof Grobelny    ],
7864b75a5bSKrzysztof Grobelny    include_directories: 'src',
7964b75a5bSKrzysztof Grobelny    install: true,
8064b75a5bSKrzysztof Grobelny    install_dir: get_option('prefix') / get_option('bindir'),
8164b75a5bSKrzysztof Grobelny    pie: true,
8264b75a5bSKrzysztof Grobelny)
8364b75a5bSKrzysztof Grobelny
8464b75a5bSKrzysztof Grobelnyconfigure_file(
8564b75a5bSKrzysztof Grobelny    input: 'xyz.openbmc_project.Telemetry.service.in',
8664b75a5bSKrzysztof Grobelny    output: 'xyz.openbmc_project.Telemetry.service',
8764b75a5bSKrzysztof Grobelny    configuration: {
8864b75a5bSKrzysztof Grobelny        'bindir': get_option('prefix') / get_option('bindir'),
8964b75a5bSKrzysztof Grobelny    },
9064b75a5bSKrzysztof Grobelny    install: true,
9164b75a5bSKrzysztof Grobelny    install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir'),
9264b75a5bSKrzysztof Grobelny)
93*73da6906SKrzysztof Grobelny
94*73da6906SKrzysztof Grobelnyif get_option('buildtest')
95*73da6906SKrzysztof Grobelny    subdir('tests')
96*73da6906SKrzysztof Grobelnyendif
97