blob: d3472da1a859e6af57a166a4e626565039f676b9 [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
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020032boost = dependency(
33 'boost',
34 version: '>=1.74.0',
35 required: false,
36 modules: ['coroutine'])
37
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020038if not boost.found()
39 subproject('boost', required: false)
Wludzik, Jozefa4bf7402020-10-21 15:08:58 +020040 boost = declare_dependency(include_directories: 'subprojects/boost_1_74_0')
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020041endif
42
43phosphor_logging = dependency('phosphor-logging', required: false)
44if not phosphor_logging.found()
45 subproject('phosphor-logging', required: false)
46 phosphor_logging = declare_dependency(
47 include_directories: 'subprojects/phosphor-logging'
48 )
49endif
50
51sdbusplus = dependency('sdbusplus',required : false)
52if not sdbusplus.found()
53 sdbusplus_proj = subproject('sdbusplus', required: true)
54 sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
55endif
56
57systemd = dependency('systemd')
58
Krzysztof Grobelny73da6902020-09-24 13:42:04 +020059if cpp.has_header('nlohmann/json.hpp')
60 nlohmann_json = declare_dependency()
61else
62 subproject('nlohmann', required: false)
63 nlohmann_json = declare_dependency(
64 include_directories: [
65 'subprojects/nlohmann/single_include',
66 'subprojects/nlohmann/single_include/nlohmann',
67 ]
68 )
69endif
70
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020071executable(
72 'telemetry',
73 [
74 'src/main.cpp',
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020075 'src/persistent_json_storage.cpp',
Wludzik, Jozefcb88cfd2020-09-28 16:38:57 +020076 'src/report.cpp',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020077 'src/report_manager.cpp',
Krzysztof Grobelnyb5645942020-09-29 11:52:45 +020078 'src/sensor.cpp',
Krzysztof Grobelny7f06f612020-09-24 13:42:10 +020079 'src/sensor_cache.cpp',
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020080 ],
81 dependencies: [
82 boost,
Krzysztof Grobelny73da6902020-09-24 13:42:04 +020083 nlohmann_json,
Krzysztof Grobelny64b75a52020-09-18 10:17:16 +020084 sdbusplus,
85 phosphor_logging,
86 ],
87 include_directories: 'src',
88 install: true,
89 install_dir: get_option('prefix') / get_option('bindir'),
90 pie: true,
91)
92
93configure_file(
94 input: 'xyz.openbmc_project.Telemetry.service.in',
95 output: 'xyz.openbmc_project.Telemetry.service',
96 configuration: {
97 'bindir': get_option('prefix') / get_option('bindir'),
98 },
99 install: true,
100 install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir'),
101)
Krzysztof Grobelny73da6902020-09-24 13:42:04 +0200102
103if get_option('buildtest')
104 subdir('tests')
105endif