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: [ |
| 6 | 'cpp_std=c++17', |
| 7 | ], |
| 8 | ) |
| 9 | |
Vijay Khemka | 3ed9a51 | 2020-08-21 16:13:05 -0700 | [diff] [blame] | 10 | cpp = meson.get_compiler('cpp') |
| 11 | if cpp.has_header('exprtk.hpp') |
| 12 | exprtk = declare_dependency() |
| 13 | else |
| 14 | subproject('exprtk', required: false) |
| 15 | exprtk = declare_dependency( |
| 16 | include_directories: 'subprojects/exprtk' |
| 17 | ) |
| 18 | endif |
| 19 | |
Patrick Williams | 8d5dff5 | 2021-04-16 10:52:54 -0500 | [diff] [blame^] | 20 | if cpp.has_header('nlomann/json.hpp') |
| 21 | nlohmann_json = declare_dependency() |
| 22 | else |
| 23 | subproject('nlohmann-json') |
| 24 | nlohmann_json = declare_dependency( |
| 25 | include_directories: [ |
| 26 | 'subprojects/nlohmann-json/single_include', |
| 27 | 'subprojects/nlohmann-json/single_include/nlohmann', |
| 28 | ] |
| 29 | ) |
| 30 | endif |
Vijay Khemka | 3ed9a51 | 2020-08-21 16:13:05 -0700 | [diff] [blame] | 31 | |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 32 | executable( |
| 33 | 'virtual-sensor', |
| 34 | [ |
| 35 | 'virtualSensor.cpp', |
| 36 | ], |
| 37 | dependencies: [ |
Patrick Williams | 8d5dff5 | 2021-04-16 10:52:54 -0500 | [diff] [blame^] | 38 | dependency( |
| 39 | 'phosphor-logging', |
| 40 | fallback: ['phosphor-logging', 'phosphor_logging_dep'], |
| 41 | ), |
| 42 | dependency( |
| 43 | 'sdbusplus', |
| 44 | fallback: ['sdbusplus', 'sdbusplus_dep' ], |
| 45 | ), |
| 46 | dependency( |
| 47 | 'phosphor-dbus-interfaces', |
| 48 | fallback: [ |
| 49 | 'phosphor-dbus-interfaces', |
| 50 | 'phosphor_dbus_interfaces_dep' |
| 51 | ], |
| 52 | ), |
| 53 | dependency( |
| 54 | 'sdeventplus', |
| 55 | fallback: ['sdeventplus', 'sdeventplus_dep'], |
| 56 | ), |
Matt Spinler | ddc6dcd | 2020-11-09 11:16:31 -0600 | [diff] [blame] | 57 | dependency('fmt'), |
Vijay Khemka | 3ed9a51 | 2020-08-21 16:13:05 -0700 | [diff] [blame] | 58 | exprtk, |
Patrick Williams | 8d5dff5 | 2021-04-16 10:52:54 -0500 | [diff] [blame^] | 59 | nlohmann_json, |
Vijay Khemka | abcc94f | 2020-08-11 15:27:44 -0700 | [diff] [blame] | 60 | ], |
| 61 | install: true, |
| 62 | install_dir: get_option('bindir') |
| 63 | ) |
| 64 | |
| 65 | packagedir = join_paths( |
| 66 | get_option('prefix'), |
| 67 | get_option('datadir'), |
| 68 | meson.project_name(), |
| 69 | ) |
| 70 | |
| 71 | configfile = 'virtual_sensor_config.json' |
| 72 | confpath = '"' + join_paths( |
| 73 | packagedir, |
| 74 | configfile, |
| 75 | ) + '"' |
| 76 | |
| 77 | install_data(sources : configfile, install_dir : packagedir) |
| 78 | |
| 79 | conf_data = configuration_data() |
| 80 | conf_data.set('VIRTUAL_SENSOR_CONFIG_FILE', confpath) |
| 81 | |
| 82 | configure_file(output : 'config.hpp', |
| 83 | configuration : conf_data) |
| 84 | |
| 85 | systemd = dependency('systemd') |
| 86 | conf_data = configuration_data() |
| 87 | conf_data.set('bindir', get_option('prefix') / get_option('bindir')) |
| 88 | configure_file( |
| 89 | input: 'phosphor-virtual-sensor.service.in', |
| 90 | output: 'phosphor-virtual-sensor.service', |
| 91 | configuration: conf_data, |
| 92 | install: true, |
| 93 | install_dir: systemd.get_pkgconfig_variable('systemdsystemunitdir')) |