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 | 202842d | 2021-04-16 16:23:39 -0500 | [diff] [blame^] | 6 | 'cpp_std=c++20', |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 7 | ], |
Patrick Williams | 202842d | 2021-04-16 16:23:39 -0500 | [diff] [blame^] | 8 | meson_version: '>=0.57.0', |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 9 | ) |
| 10 | |
Vijay Khemka | 3ed9a51 | 2020-08-21 16:13:05 -0700 | [diff] [blame] | 11 | cpp = meson.get_compiler('cpp') |
| 12 | if cpp.has_header('exprtk.hpp') |
| 13 | exprtk = declare_dependency() |
| 14 | else |
| 15 | subproject('exprtk', required: false) |
| 16 | exprtk = declare_dependency( |
| 17 | include_directories: 'subprojects/exprtk' |
| 18 | ) |
| 19 | endif |
| 20 | |
Patrick Williams | 8d5dff5 | 2021-04-16 10:52:54 -0500 | [diff] [blame] | 21 | if cpp.has_header('nlomann/json.hpp') |
| 22 | nlohmann_json = declare_dependency() |
| 23 | else |
| 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 | ) |
| 31 | endif |
Vijay Khemka | 3ed9a51 | 2020-08-21 16:13:05 -0700 | [diff] [blame] | 32 | |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 33 | executable( |
| 34 | 'virtual-sensor', |
| 35 | [ |
| 36 | 'virtualSensor.cpp', |
| 37 | ], |
| 38 | dependencies: [ |
Patrick Williams | 8d5dff5 | 2021-04-16 10:52:54 -0500 | [diff] [blame] | 39 | 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 Spinler | ddc6dcd | 2020-11-09 11:16:31 -0600 | [diff] [blame] | 58 | dependency('fmt'), |
Vijay Khemka | 3ed9a51 | 2020-08-21 16:13:05 -0700 | [diff] [blame] | 59 | exprtk, |
Patrick Williams | 8d5dff5 | 2021-04-16 10:52:54 -0500 | [diff] [blame] | 60 | nlohmann_json, |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 61 | ], |
| 62 | install: true, |
| 63 | install_dir: get_option('bindir') |
| 64 | ) |
| 65 | |
| 66 | packagedir = join_paths( |
| 67 | get_option('prefix'), |
| 68 | get_option('datadir'), |
| 69 | meson.project_name(), |
| 70 | ) |
| 71 | |
| 72 | configfile = 'virtual_sensor_config.json' |
| 73 | confpath = '"' + join_paths( |
| 74 | packagedir, |
| 75 | configfile, |
| 76 | ) + '"' |
| 77 | |
| 78 | install_data(sources : configfile, install_dir : packagedir) |
| 79 | |
| 80 | conf_data = configuration_data() |
| 81 | conf_data.set('VIRTUAL_SENSOR_CONFIG_FILE', confpath) |
| 82 | |
| 83 | configure_file(output : 'config.hpp', |
| 84 | configuration : conf_data) |
| 85 | |
| 86 | systemd = dependency('systemd') |
| 87 | conf_data = configuration_data() |
| 88 | conf_data.set('bindir', get_option('prefix') / get_option('bindir')) |
| 89 | configure_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')) |