xref: /openbmc/google-ipmi-sys/meson.build (revision 6c71b0f9)
1project(
2  'google-ipmi-sys',
3  'cpp',
4  version: '0.1',
5  meson_version: '>=0.57.0',
6  default_options: [
7    'cpp_std=c++20',
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
20meson.get_compiler('cpp').has_header_symbol(
21  'ipmid/api.h',
22  'ipmid_get_sd_bus_connection')
23
24json_dep = dependency('nlohmann_json', required: false)
25meson.get_compiler('cpp').has_header_symbol(
26  'nlohmann/json.hpp',
27  'nlohmann::json',
28  dependencies: json_dep)
29
30fmt_dep = dependency('fmt', required: false)
31if not fmt_dep.found()
32  fmt_proj = import('cmake').subproject(
33    'fmt',
34    cmake_options: [
35      '-DCMAKE_POSITION_INDEPENDENT_CODE=ON',
36      '-DMASTER_PROJECT=OFF'
37    ],
38    required: false)
39  assert(fmt_proj.found(), 'fmtlib is required')
40  fmt_dep = fmt_proj.dependency('fmt')
41endif
42
43subdir('bifurcation')
44
45sys_pre = declare_dependency(
46  include_directories: root_inc,
47  dependencies: [
48    json_dep,
49    fmt_dep,
50    dependency('phosphor-dbus-interfaces'),
51    dependency('phosphor-logging'),
52    dependency('sdbusplus'),
53    bifurcation_dep,
54  ])
55
56sys_lib = static_library(
57  'sys',
58  'cable.cpp',
59  'cpld.cpp',
60  'entity_name.cpp',
61  'eth.cpp',
62  'flash_size.cpp',
63  'handler.cpp',
64  'host_power_off.cpp',
65  'ipmi.cpp',
66  'machine_name.cpp',
67  'pcie_i2c.cpp',
68  'google_accel_oob.cpp',
69  'pcie_bifurcation.cpp',
70  'psu.cpp',
71  'util.cpp',
72  implicit_include_directories: false,
73  dependencies: sys_pre)
74
75sys_dep = declare_dependency(
76  link_with: sys_lib,
77  dependencies: sys_pre)
78
79if not get_option('tests').disabled()
80  subdir('test')
81endif
82
83shared_module(
84  'googlesys',
85  'main.cpp',
86  implicit_include_directories: false,
87  dependencies: [
88    dependency('libipmid'),
89    sys_dep,
90  ],
91  install: true,
92  install_dir: get_option('libdir') / 'ipmid-providers')
93
94systemd_dep = dependency('systemd')
95if systemd_dep.found()
96  install_data(
97    'gbmc-host-poweroff.target',
98    'gbmc-psu-hardreset.target',
99    'gbmc-psu-hardreset-pre.target',
100    'gbmc-psu-hardreset-time.service',
101    install_dir: systemd_dep.get_variable(pkgconfig: 'systemdsystemunitdir'))
102endif
103