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