blob: 42bd59fbfd915cb0dd8bd6088715f7d0177c16fc [file] [log] [blame]
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +02001project(
2 'Telemetry',
3 'cpp',
4 meson_version: '>=0.55.0',
5 default_options: [
6 'buildtype=debugoptimized',
7 'cpp_std=c++17',
Wludzik, Jozefa4bf7402020-10-21 15:08:58 +02008 # TODO: Without RTTI telemetry does not build using Boost 1.74.0
9 # https://github.com/chriskohlhoff/asio/issues/533
10 #'cpp_rtti=false',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020011 '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
Wludzik, Jozefa4bf7402020-10-21 15:08:58 +020032boost = dependency('boost', version: '>=1.74.0', required: false)
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020033if not boost.found()
34 subproject('boost', required: false)
Wludzik, Jozefa4bf7402020-10-21 15:08:58 +020035 boost = declare_dependency(include_directories: 'subprojects/boost_1_74_0')
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020036endif
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
Krzysztof Grobelny73da6902020-09-24 13:42:04 +020054if 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
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020066executable(
67 'telemetry',
68 [
69 'src/main.cpp',
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020070 'src/report.cpp',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020071 'src/report_manager.cpp',
Krzysztof Grobelny73da6902020-09-24 13:42:04 +020072 'src/persistent_json_storage.cpp',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020073 ],
74 dependencies: [
75 boost,
Krzysztof Grobelny73da6902020-09-24 13:42:04 +020076 nlohmann_json,
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020077 sdbusplus,
78 phosphor_logging,
79 ],
80 include_directories: 'src',
81 install: true,
82 install_dir: get_option('prefix') / get_option('bindir'),
83 pie: true,
84)
85
86configure_file(
87 input: 'xyz.openbmc_project.Telemetry.service.in',
88 output: 'xyz.openbmc_project.Telemetry.service',
89 configuration: {
90 'bindir': get_option('prefix') / get_option('bindir'),
91 },
92 install: true,
93 install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir'),
94)
Krzysztof Grobelny73da6902020-09-24 13:42:04 +020095
96if get_option('buildtest')
97 subdir('tests')
98endif