blob: 8fcb47e55c971afe7e1fc1c068b28d158fb2f28e [file] [log] [blame]
Vijay Khemkaabcc94f2020-08-11 15:27:44 -07001project(
2 'phosphor-virtual-sensor',
3 'cpp',
4 version: '1.0',
5 default_options: [
6 'cpp_std=c++17',
7 ],
8)
9
Vijay Khemka3ed9a512020-08-21 16:13:05 -070010cpp = meson.get_compiler('cpp')
11if cpp.has_header('exprtk.hpp')
12 exprtk = declare_dependency()
13else
14 subproject('exprtk', required: false)
15 exprtk = declare_dependency(
16 include_directories: 'subprojects/exprtk'
17 )
18endif
19
Patrick Williams8d5dff52021-04-16 10:52:54 -050020if cpp.has_header('nlomann/json.hpp')
21 nlohmann_json = declare_dependency()
22else
23 subproject('nlohmann-json')
24 nlohmann_json = declare_dependency(
25 include_directories: [
26 'subprojects/nlohmann-json/single_include',
27 'subprojects/nlohmann-json/single_include/nlohmann',
28 ]
29 )
30endif
Vijay Khemka3ed9a512020-08-21 16:13:05 -070031
Vijay Khemkaabcc94f2020-08-11 15:27:44 -070032executable(
33 'virtual-sensor',
34 [
35 'virtualSensor.cpp',
36 ],
37 dependencies: [
Patrick Williams8d5dff52021-04-16 10:52:54 -050038 dependency(
39 'phosphor-logging',
40 fallback: ['phosphor-logging', 'phosphor_logging_dep'],
41 ),
42 dependency(
43 'sdbusplus',
44 fallback: ['sdbusplus', 'sdbusplus_dep' ],
45 ),
46 dependency(
47 'phosphor-dbus-interfaces',
48 fallback: [
49 'phosphor-dbus-interfaces',
50 'phosphor_dbus_interfaces_dep'
51 ],
52 ),
53 dependency(
54 'sdeventplus',
55 fallback: ['sdeventplus', 'sdeventplus_dep'],
56 ),
Matt Spinlerddc6dcd2020-11-09 11:16:31 -060057 dependency('fmt'),
Vijay Khemka3ed9a512020-08-21 16:13:05 -070058 exprtk,
Patrick Williams8d5dff52021-04-16 10:52:54 -050059 nlohmann_json,
Vijay Khemkaabcc94f2020-08-11 15:27:44 -070060 ],
61 install: true,
62 install_dir: get_option('bindir')
63)
64
65packagedir = join_paths(
66 get_option('prefix'),
67 get_option('datadir'),
68 meson.project_name(),
69)
70
71configfile = 'virtual_sensor_config.json'
72confpath = '"' + join_paths(
73 packagedir,
74 configfile,
75) + '"'
76
77install_data(sources : configfile, install_dir : packagedir)
78
79conf_data = configuration_data()
80conf_data.set('VIRTUAL_SENSOR_CONFIG_FILE', confpath)
81
82configure_file(output : 'config.hpp',
83 configuration : conf_data)
84
85systemd = dependency('systemd')
86conf_data = configuration_data()
87conf_data.set('bindir', get_option('prefix') / get_option('bindir'))
88configure_file(
89 input: 'phosphor-virtual-sensor.service.in',
90 output: 'phosphor-virtual-sensor.service',
91 configuration: conf_data,
92 install: true,
93 install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir'))