1project(
2    'phosphor-ledmanager', 'cpp',
3    version : '1.0.0',
4    meson_version: '>=1.1.1',
5    default_options: [
6        'warning_level=3',
7        'werror=true',
8        'cpp_std=c++23',
9        'buildtype=debugoptimized',
10    ]
11)
12
13cpp = meson.get_compiler('cpp')
14
15conf_data = configuration_data()
16conf_data.set_quoted('LED_JSON_FILE', '/usr/share/phosphor-led-manager/led-group-config.json')
17conf_data.set_quoted('SAVED_GROUPS_FILE', '/var/lib/phosphor-led-manager/savedGroups')
18conf_data.set_quoted('CALLOUT_FWD_ASSOCIATION', 'callout')
19conf_data.set_quoted('CALLOUT_REV_ASSOCIATION', 'fault')
20conf_data.set_quoted('ELOG_ENTRY', 'entry')
21conf_data.set_quoted('LED_FAULT', 'fault')
22
23conf_data.set('CLASS_VERSION', 1)
24conf_data.set('LED_USE_JSON', get_option('use-json').allowed())
25conf_data.set('USE_LAMP_TEST', get_option('use-lamp-test').allowed())
26conf_data.set('MONITOR_OPERATIONAL_STATUS', get_option('monitor-operational-status').allowed())
27conf_data.set('PERSISTENT_LED_ASSERTED', get_option('persistent-led-asserted').allowed())
28
29nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
30phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
31phosphor_logging_dep = dependency('phosphor-logging')
32sdbusplus_dep = dependency('sdbusplus')
33sdeventplus_dep = dependency('sdeventplus')
34
35prog_python = find_program('python3', required: true)
36realpath_prog = find_program('realpath')
37
38
39if cpp.has_header('CLI/CLI.hpp')
40    CLI11_dep = declare_dependency()
41else
42    CLI11_dep = dependency('CLI11')
43endif
44
45# Get Cereal dependency.
46cereal_dep = dependency('cereal', required: false)
47has_cereal = cpp.has_header_symbol(
48    'cereal/cereal.hpp',
49    'cereal::specialize',
50    dependencies: cereal_dep,
51    required: false)
52if not has_cereal
53    cereal_opts = import('cmake').subproject_options()
54    cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
55    cereal_proj = import('cmake').subproject(
56        'cereal',
57        options: cereal_opts,
58        required: false)
59    assert(cereal_proj.found(), 'cereal is required')
60    cereal_dep = cereal_proj.dependency('cereal')
61endif
62
63deps = [
64    CLI11_dep,
65    cereal_dep,
66    nlohmann_json_dep,
67    phosphor_dbus_interfaces_dep,
68    phosphor_logging_dep,
69    sdbusplus_dep,
70    sdeventplus_dep,
71]
72
73subdir('manager')
74subdir('fault-monitor')
75
76configure_file(output: 'config.h',
77    configuration: conf_data
78)
79
80install_data(
81    'scripts/led-set-all-groups-asserted.sh',
82    install_dir: get_option('bindir')
83)
84
85if get_option('tests').allowed()
86  subdir('test')
87endif
88
89install_subdir('configs',
90    install_dir: get_option('datadir') / 'phosphor-led-manager',
91    strip_directory: true)
92