blob: 0ca55adf4cb6834cda7fb124532291d4130f1890 [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 Williamsce4241c2023-07-12 11:15:56 -05007 'cpp_std=c++23',
Patrick Williamsff2df992021-08-26 10:23:08 -05008 'warning_level=3',
9 'werror=true',
Vijay Khemkaabcc94f2020-08-11 15:27:44 -070010 ],
Patrick Williamsce4241c2023-07-12 11:15:56 -050011 meson_version: '>=1.1.1',
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',
Tao Linf2e94222023-10-31 17:38:17 +080040 'dbusSensor.cpp',
41 'dbusUtils.cpp',
Vijay Khemkaabcc94f2020-08-11 15:27:44 -070042 ],
43 dependencies: [
Patrick Williamsb729eac2022-03-21 10:14:47 -050044 dependency('phosphor-dbus-interfaces'),
45 dependency('phosphor-logging'),
46 dependency('sdbusplus'),
Vijay Khemka3ed9a512020-08-21 16:13:05 -070047 exprtk,
Patrick Williams8d5dff52021-04-16 10:52:54 -050048 nlohmann_json,
Vijay Khemkaabcc94f2020-08-11 15:27:44 -070049 ],
50 install: true,
51 install_dir: get_option('bindir')
52)
53
54packagedir = join_paths(
55 get_option('prefix'),
56 get_option('datadir'),
57 meson.project_name(),
58)
59
Patrick Williams32dff212023-02-09 13:54:18 -060060install_data(sources : 'virtual_sensor_config.json', install_dir : packagedir)
Vijay Khemkaabcc94f2020-08-11 15:27:44 -070061
62systemd = dependency('systemd')
63conf_data = configuration_data()
64conf_data.set('bindir', get_option('prefix') / get_option('bindir'))
65configure_file(
66 input: 'phosphor-virtual-sensor.service.in',
67 output: 'phosphor-virtual-sensor.service',
68 configuration: conf_data,
69 install: true,
Patrick Williams209a8802023-04-12 08:01:25 -050070 install_dir: systemd.get_variable('systemdsystemunitdir'))
Lei YU14ef8742023-10-07 17:50:28 +080071
72build_tests = get_option('tests')
73if not build_tests.disabled()
74 subdir('test')
75endif