xref: /openbmc/google-ipmi-sys/meson.build (revision 99413410)
1project(
2  'google-ipmi-sys',
3  'cpp',
4  version: '0.1',
5  meson_version: '>=1.1.1',
6  default_options: [
7    'cpp_std=c++23',
8    'warning_level=3',
9    'werror=true',
10  ])
11
12root_inc = include_directories('.')
13
14conf_data = configuration_data()
15conf_data.set_quoted('STATIC_BIFURCATION_CONFIG', get_option('static-bifurcation'))
16conf_h = configure_file(
17  output: 'config.h',
18  configuration: conf_data)
19
20bm_conf_data = configuration_data()
21bm_conf_data.set10('BARE_METAL', get_option('bare_metal'))
22bm_conf_data.set_quoted('BM_SIGNAL_PATH', get_option('bm-signal-path'))
23bm_conf_h = configure_file(
24  output: 'bm_config.h',
25  configuration: bm_conf_data)
26
27meson.get_compiler('cpp').has_header_symbol(
28  'ipmid/api.h',
29  'ipmid_get_sd_bus_connection')
30
31json_dep = dependency('nlohmann_json', required: false)
32meson.get_compiler('cpp').has_header_symbol(
33  'nlohmann/json.hpp',
34  'nlohmann::json',
35  dependencies: json_dep)
36
37fmt_dep = dependency('fmt', required: false)
38if not fmt_dep.found()
39  fmt_proj = import('cmake').subproject(
40    'fmt',
41    cmake_options: [
42      '-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
43      '-DMASTER_PROJECT=OFF'
44    ],
45    required: false)
46  assert(fmt_proj.found(), 'fmtlib is required')
47  fmt_dep = fmt_proj.dependency('fmt')
48endif
49
50subdir('bifurcation')
51
52sys_pre = declare_dependency(
53  include_directories: root_inc,
54  dependencies: [
55    json_dep,
56    fmt_dep,
57    dependency('phosphor-dbus-interfaces'),
58    dependency('phosphor-logging'),
59    dependency('sdbusplus'),
60    bifurcation_dep,
61  ])
62
63sys_lib = static_library(
64  'sys',
65  'bmc_mode.cpp',
66  'cable.cpp',
67  'cpld.cpp',
68  'entity_name.cpp',
69  'eth.cpp',
70  'flash_size.cpp',
71  'handler.cpp',
72  'host_power_off.cpp',
73  'ipmi.cpp',
74  'linux_boot_done.cpp',
75  'machine_name.cpp',
76  'pcie_i2c.cpp',
77  'google_accel_oob.cpp',
78  'pcie_bifurcation.cpp',
79  'psu.cpp',
80  'util.cpp',
81  implicit_include_directories: false,
82  dependencies: sys_pre)
83
84sys_dep = declare_dependency(
85  link_with: sys_lib,
86  dependencies: sys_pre)
87
88if not get_option('tests').disabled()
89  subdir('test')
90endif
91
92shared_module(
93  'googlesys',
94  'main.cpp',
95  implicit_include_directories: false,
96  dependencies: [
97    dependency('libipmid'),
98    sys_dep,
99  ],
100  install: true,
101  install_dir: get_option('libdir') / 'ipmid-providers')
102
103systemd_dep = dependency('systemd')
104if systemd_dep.found()
105  install_data(
106    'gbmc-bare-metal-active.target',
107    'gbmc-host-poweroff.target',
108    'gbmc-psu-hardreset.target',
109    'gbmc-psu-hardreset-pre.target',
110    'gbmc-psu-hardreset-time.service',
111    install_dir: systemd_dep.get_variable('systemdsystemunitdir'))
112endif
113