xref: /openbmc/pldm/meson.build (revision a1d27606bc7da14081770ca310012768b933f6e7)
1project('pldm', ['c', 'cpp'],
2        version: '0.1', meson_version: '>=0.57.0',
3        default_options: [
4          'warning_level=3',
5          'default_library=shared',
6          'werror=true',
7          'cpp_std=c++20',
8          'buildtype=debugoptimized'
9        ])
10
11# Wno-psabi reduces the number of "Note:" messages when cross-compiling some STL
12# stuff for ARM. See https://stackoverflow.com/questions/48149323/strange-gcc-warning-when-compiling-qt-project
13# Basically, gcc 6 and gcc 7 are not ABI compatible, but since the whole OpenBMC
14# project uses the same compiler, we can safely ignmore these info notes.
15add_project_arguments('-Wno-psabi', language: 'cpp')
16
17
18# Disable FORTIFY_SOURCE when compiling with no optimization
19if(get_option('optimization') == '0')
20  add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c'])
21  message('Disabling FORTIFY_SOURCE as optimization is set to 0')
22endif
23
24conf_data = configuration_data()
25conf_data.set_quoted('BIOS_JSONS_DIR', '/usr/share/pldm/bios')
26conf_data.set_quoted('BIOS_TABLES_DIR', '/var/lib/pldm/bios')
27conf_data.set_quoted('PDR_JSONS_DIR', '/usr/share/pldm/pdr')
28conf_data.set_quoted('FRU_JSONS_DIR', '/usr/share/pldm/fru')
29conf_data.set_quoted('HOST_JSONS_DIR', '/usr/share/pldm/host')
30conf_data.set_quoted('EVENTS_JSONS_DIR', '/usr/share/pldm/events')
31conf_data.set('PLDM_VERBOSITY',get_option('verbosity'))
32if get_option('softoff').enabled()
33  conf_data.set('SOFTOFF_TIMEOUT_SECONDS', get_option('softoff-timeout-seconds'))
34endif
35if get_option('oem-ibm').enabled()
36  conf_data.set_quoted('FILE_TABLE_JSON', '/usr/share/pldm/fileTable.json')
37  conf_data.set_quoted('LID_RUNNING_DIR', '/var/lib/phosphor-software-manager/hostfw/running')
38  conf_data.set_quoted('LID_ALTERNATE_DIR', '/var/lib/phosphor-software-manager/hostfw/alternate')
39  conf_data.set_quoted('LID_STAGING_DIR', '/var/lib/phosphor-software-manager/hostfw/staging')
40  conf_data.set_quoted('LID_RUNNING_PATCH_DIR', '/usr/local/share/hostfw/running')
41  conf_data.set_quoted('LID_ALTERNATE_PATCH_DIR', '/usr/local/share/hostfw/alternate')
42  conf_data.set_quoted('LID_STAGING_DIR', '/var/lib/phosphor-software-manager/hostfw/staging')
43  conf_data.set('DMA_MAXSIZE', get_option('oem-ibm-dma-maxsize'))
44  add_project_arguments('-DOEM_IBM', language : 'c')
45  add_project_arguments('-DOEM_IBM', language : 'cpp')
46endif
47configure_file(output: 'config.h',
48  configuration: conf_data
49)
50
51phosphor_dbus_interfaces = dependency(
52  'phosphor-dbus-interfaces',
53  fallback: ['phosphor-dbus-interfaces', 'phosphor_dbus_interfaces_dep'],
54)
55sdbusplus = dependency(
56  'sdbusplus',
57  fallback: ['sdbusplus', 'sdbusplus_dep'],
58)
59sdeventplus = dependency(
60  'sdeventplus',
61  fallback: ['sdeventplus', 'sdeventplus_dep'],
62)
63systemd = dependency('systemd')
64
65cpp = meson.get_compiler('cpp')
66
67if cpp.has_header('nlohmann/json.hpp')
68  nlohmann_json = declare_dependency()
69else
70  subproject('nlohmann-json')
71  nlohmann_json = declare_dependency(
72    include_directories: [
73      'subprojects/nlohmann-json/single_include',
74      'subprojects/nlohmann-json/single_include/nlohmann',
75    ]
76  )
77endif
78
79if cpp.has_header('CLI/CLI.hpp')
80  CLI11_dep = declare_dependency()
81else
82  CLI11_dep = dependency(
83    'CLI11',
84    fallback: [ 'CLI11', 'CLI11_dep' ],
85  )
86endif
87
88
89subdir('libpldm')
90
91if get_option('libpldm-only').disabled()
92
93libpldmutils_headers = ['.']
94libpldmutils = library(
95  'pldmutils',
96  'common/utils.cpp',
97  version: meson.project_version(),
98  dependencies: [
99      libpldm_dep,
100      phosphor_dbus_interfaces,
101      nlohmann_json,
102      sdbusplus,
103  ],
104  install: true,
105  include_directories: include_directories(libpldmutils_headers),
106)
107
108libpldmutils = declare_dependency(
109  include_directories: include_directories(libpldmutils_headers),
110  link_with: libpldmutils)
111subdir('libpldmresponder')
112
113deps = [
114  libpldm_dep,
115  libpldmutils,
116  libpldmresponder,
117  libpldmutils,
118  nlohmann_json,
119  sdbusplus,
120  sdeventplus,
121  phosphor_dbus_interfaces
122]
123
124executable(
125  'pldmd',
126  'pldmd/pldmd.cpp',
127  'pldmd/dbus_impl_requester.cpp',
128  'pldmd/instance_id.cpp',
129  'pldmd/dbus_impl_pdr.cpp',
130  'host-bmc/dbus_to_host_effecters.cpp',
131  implicit_include_directories: false,
132  dependencies: deps,
133  install: true,
134  install_dir: get_option('bindir'))
135
136systemd_system_unit_dir = systemd.get_variable(
137        pkgconfig: 'systemdsystemunitdir',
138        pkgconfig_define: ['prefix', get_option('prefix')])
139
140configure_file(
141  copy: true,
142  input: 'pldmd/service_files/pldmd.service',
143  install: true,
144  install_dir: systemd_system_unit_dir,
145  output: 'pldmd.service',
146)
147
148configure_file(
149  input: 'pldmd/verbosity/verbosity',
150  output: 'pldm_verbosity',
151  configuration: conf_data,
152  install: true,
153  install_dir: '/etc/default')
154
155if get_option('oem-ibm').enabled()
156  subdir('oem/ibm/service_files')
157endif
158
159subdir('pldmtool')
160
161subdir('configurations')
162
163if get_option('tests').enabled()
164  subdir('test')
165endif
166
167if get_option('utilities').enabled()
168  subdir('utilities')
169endif
170
171if get_option('softoff').enabled()
172  subdir('softoff')
173endif
174
175endif # pldm-only
176