xref: /openbmc/phosphor-led-manager/meson.build (revision 953315d272bec972252fc8bb1cd393f03ac56be8)
1project(
2    'phosphor-ledmanager', 'cpp',
3    version : '1.0.0',
4    meson_version: '>=0.57.0',
5    default_options: [
6        'warning_level=3',
7        'werror=true',
8        'cpp_std=c++20',
9        'buildtype=debugoptimized',
10    ]
11)
12
13conf_data = configuration_data()
14conf_data.set_quoted('BUSNAME', 'xyz.openbmc_project.LED.GroupManager')
15conf_data.set_quoted('OBJPATH', '/xyz/openbmc_project/led/groups')
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').enabled())
25conf_data.set('USE_LAMP_TEST', get_option('use-lamp-test').enabled())
26conf_data.set('MONITOR_OPERATIONAL_STATUS', get_option('monitor-operational-status').enabled())
27
28sdbusplus_dep = dependency('sdbusplus')
29
30sdeventplus_dep = dependency(
31    'sdeventplus',
32    fallback: [
33        'sdeventplus',
34        'sdeventplus_dep'
35    ],
36)
37phosphor_logging_dep = dependency(
38    'phosphor-logging',
39    fallback: [
40        'phosphor-logging',
41        'phosphor_logging_dep'
42    ],
43)
44phosphor_dbus_interfaces_dep = dependency(
45    'phosphor-dbus-interfaces',
46    fallback: [
47        'phosphor-dbus-interfaces',
48        'phosphor_dbus_interfaces_dep'
49    ],
50)
51prog_python = find_program('python3', required: true)
52realpath_prog = find_program('realpath')
53
54cpp = meson.get_compiler('cpp')
55if cpp.has_header('nlohmann/json.hpp')
56    nlohmann_json_dep = declare_dependency()
57else
58    subproject('nlohmann', required: false)
59    nlohmann_json_dep = declare_dependency(
60        include_directories: [
61            'subprojects/nlohmann/single_include',
62            'subprojects/nlohmann/single_include/nlohmann',
63        ]
64    )
65endif
66
67# Get Cereal dependency.
68cereal_dep = dependency('cereal', required: false)
69has_cereal = cpp.has_header_symbol(
70    'cereal/cereal.hpp',
71    'cereal::specialize',
72    dependencies: cereal_dep,
73    required: false)
74if not has_cereal
75    cereal_opts = import('cmake').subproject_options()
76    cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
77    cereal_proj = import('cmake').subproject(
78        'cereal',
79        options: cereal_opts,
80        required: false)
81    assert(cereal_proj.found(), 'cereal is required')
82    cereal_dep = cereal_proj.dependency('cereal')
83endif
84
85deps = [
86    sdbusplus_dep,
87    sdeventplus_dep,
88    phosphor_logging_dep,
89    phosphor_dbus_interfaces_dep,
90    nlohmann_json_dep,
91    cereal_dep,
92]
93
94subdir('manager')
95subdir('fault-monitor')
96
97configure_file(output: 'config.h',
98    configuration: conf_data
99)
100
101install_data(
102    'scripts/led-set-all-groups-asserted.sh',
103    install_dir: get_option('bindir')
104)
105
106build_tests = get_option('tests')
107if not build_tests.disabled()
108  subdir('test')
109endif
110
111install_subdir('configs',
112    install_dir: get_option('datadir') / 'phosphor-led-manager',
113    strip_directory: true)
114