Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 1 | project( |
| 2 | 'phosphor-virtual-sensor', |
| 3 | 'cpp', |
| 4 | version: '1.0', |
| 5 | default_options: [ |
Patrick Williams | ff2df99 | 2021-08-26 10:23:08 -0500 | [diff] [blame] | 6 | 'buildtype=debugoptimized', |
Patrick Williams | 202842d | 2021-04-16 16:23:39 -0500 | [diff] [blame] | 7 | 'cpp_std=c++20', |
Patrick Williams | ff2df99 | 2021-08-26 10:23:08 -0500 | [diff] [blame] | 8 | 'warning_level=3', |
| 9 | 'werror=true', |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 10 | ], |
Patrick Williams | 202842d | 2021-04-16 16:23:39 -0500 | [diff] [blame] | 11 | meson_version: '>=0.57.0', |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 12 | ) |
| 13 | |
Vijay Khemka | 3ed9a51 | 2020-08-21 16:13:05 -0700 | [diff] [blame] | 14 | cpp = meson.get_compiler('cpp') |
| 15 | if cpp.has_header('exprtk.hpp') |
| 16 | exprtk = declare_dependency() |
| 17 | else |
| 18 | subproject('exprtk', required: false) |
| 19 | exprtk = declare_dependency( |
| 20 | include_directories: 'subprojects/exprtk' |
| 21 | ) |
| 22 | endif |
| 23 | |
Patrick Williams | d9aa227 | 2021-04-27 16:38:07 -0500 | [diff] [blame] | 24 | if cpp.has_header('nlohmann/json.hpp') |
Patrick Williams | 8d5dff5 | 2021-04-16 10:52:54 -0500 | [diff] [blame] | 25 | nlohmann_json = declare_dependency() |
| 26 | else |
| 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 | ) |
| 34 | endif |
Vijay Khemka | 3ed9a51 | 2020-08-21 16:13:05 -0700 | [diff] [blame] | 35 | |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 36 | executable( |
| 37 | 'virtual-sensor', |
| 38 | [ |
| 39 | 'virtualSensor.cpp', |
| 40 | ], |
| 41 | dependencies: [ |
Patrick Williams | b729eac | 2022-03-21 10:14:47 -0500 | [diff] [blame] | 42 | dependency('phosphor-dbus-interfaces'), |
| 43 | dependency('phosphor-logging'), |
| 44 | dependency('sdbusplus'), |
| 45 | dependency('sdeventplus'), |
Vijay Khemka | 3ed9a51 | 2020-08-21 16:13:05 -0700 | [diff] [blame] | 46 | exprtk, |
Patrick Williams | 8d5dff5 | 2021-04-16 10:52:54 -0500 | [diff] [blame] | 47 | nlohmann_json, |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 48 | ], |
| 49 | install: true, |
| 50 | install_dir: get_option('bindir') |
| 51 | ) |
| 52 | |
| 53 | packagedir = join_paths( |
| 54 | get_option('prefix'), |
| 55 | get_option('datadir'), |
| 56 | meson.project_name(), |
| 57 | ) |
| 58 | |
| 59 | configfile = 'virtual_sensor_config.json' |
| 60 | confpath = '"' + join_paths( |
| 61 | packagedir, |
| 62 | configfile, |
| 63 | ) + '"' |
| 64 | |
| 65 | install_data(sources : configfile, install_dir : packagedir) |
| 66 | |
| 67 | conf_data = configuration_data() |
| 68 | conf_data.set('VIRTUAL_SENSOR_CONFIG_FILE', confpath) |
| 69 | |
| 70 | configure_file(output : 'config.hpp', |
| 71 | configuration : conf_data) |
| 72 | |
| 73 | systemd = dependency('systemd') |
| 74 | conf_data = configuration_data() |
| 75 | conf_data.set('bindir', get_option('prefix') / get_option('bindir')) |
| 76 | configure_file( |
| 77 | input: 'phosphor-virtual-sensor.service.in', |
| 78 | output: 'phosphor-virtual-sensor.service', |
| 79 | configuration: conf_data, |
| 80 | install: true, |
George Liu | fe3214e | 2021-12-29 15:00:57 +0800 | [diff] [blame] | 81 | install_dir: systemd.get_variable(pkgconfig: 'systemdsystemunitdir')) |