blob: 5ff07fb9d466f2ee244cda8b3df9e7e827c6d407 [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 Williamsff2df992021-08-26 10:23:08 -05006 'buildtype=debugoptimized',
Patrick Williams202842d2021-04-16 16:23:39 -05007 'cpp_std=c++20',
Patrick Williamsff2df992021-08-26 10:23:08 -05008 'warning_level=3',
9 'werror=true',
Vijay Khemkaabcc94f2020-08-11 15:27:44 -070010 ],
Patrick Williams202842d2021-04-16 16:23:39 -050011 meson_version: '>=0.57.0',
Vijay Khemkaabcc94f2020-08-11 15:27:44 -070012)
13
Vijay Khemka3ed9a512020-08-21 16:13:05 -070014cpp = meson.get_compiler('cpp')
15if cpp.has_header('exprtk.hpp')
16 exprtk = declare_dependency()
17else
18 subproject('exprtk', required: false)
19 exprtk = declare_dependency(
20 include_directories: 'subprojects/exprtk'
21 )
22endif
23
Patrick Williamsd9aa2272021-04-27 16:38:07 -050024if cpp.has_header('nlohmann/json.hpp')
Patrick Williams8d5dff52021-04-16 10:52:54 -050025 nlohmann_json = declare_dependency()
26else
27 subproject('nlohmann-json')
28 nlohmann_json = declare_dependency(
29 include_directories: [
30 'subprojects/nlohmann-json/single_include',
31 'subprojects/nlohmann-json/single_include/nlohmann',
32 ]
33 )
34endif
Vijay Khemka3ed9a512020-08-21 16:13:05 -070035
Vijay Khemkaabcc94f2020-08-11 15:27:44 -070036executable(
37 'virtual-sensor',
38 [
39 'virtualSensor.cpp',
40 ],
41 dependencies: [
Patrick Williams8d5dff52021-04-16 10:52:54 -050042 dependency(
43 'phosphor-logging',
44 fallback: ['phosphor-logging', 'phosphor_logging_dep'],
45 ),
46 dependency(
47 'sdbusplus',
48 fallback: ['sdbusplus', 'sdbusplus_dep' ],
49 ),
50 dependency(
51 'phosphor-dbus-interfaces',
52 fallback: [
53 'phosphor-dbus-interfaces',
54 'phosphor_dbus_interfaces_dep'
55 ],
56 ),
57 dependency(
58 'sdeventplus',
59 fallback: ['sdeventplus', 'sdeventplus_dep'],
60 ),
Vijay Khemka3ed9a512020-08-21 16:13:05 -070061 exprtk,
Patrick Williams8d5dff52021-04-16 10:52:54 -050062 nlohmann_json,
Vijay Khemkaabcc94f2020-08-11 15:27:44 -070063 ],
64 install: true,
65 install_dir: get_option('bindir')
66)
67
68packagedir = join_paths(
69 get_option('prefix'),
70 get_option('datadir'),
71 meson.project_name(),
72)
73
74configfile = 'virtual_sensor_config.json'
75confpath = '"' + join_paths(
76 packagedir,
77 configfile,
78) + '"'
79
80install_data(sources : configfile, install_dir : packagedir)
81
82conf_data = configuration_data()
83conf_data.set('VIRTUAL_SENSOR_CONFIG_FILE', confpath)
84
85configure_file(output : 'config.hpp',
86 configuration : conf_data)
87
88systemd = dependency('systemd')
89conf_data = configuration_data()
90conf_data.set('bindir', get_option('prefix') / get_option('bindir'))
91configure_file(
92 input: 'phosphor-virtual-sensor.service.in',
93 output: 'phosphor-virtual-sensor.service',
94 configuration: conf_data,
95 install: true,
96 install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir'))