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