1project(
2    'post-code-manager',
3    'cpp',
4    default_options: [
5        'cpp_std=c++20',
6        'warning_level=3',
7        'werror=true',
8    ],
9    license: 'Apache-2.0',
10    meson_version: '>=0.57.0',
11    version: '1.0',
12)
13
14
15conf_data = configuration_data()
16conf_data.set_quoted('DBUS_OBJECT_NAME', '/xyz/openbmc_project/State/Boot/PostCode0')
17conf_data.set_quoted('DBUS_INTF_NAME','xyz.openbmc_project.State.Boot.PostCode')
18conf_data.set('MAX_BOOT_CYCLE_COUNT',get_option('max-boot-cycle-count'))
19
20if get_option('bios-post-code-log').enabled()
21  add_project_arguments('-DENABLE_BIOS_POST_CODE_LOG',language: 'cpp')
22endif
23
24configure_file(output: 'config.h',
25  configuration: conf_data
26)
27
28sdbusplus = dependency('sdbusplus')
29phosphor_logging = dependency('phosphor-logging')
30phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
31
32cxx = meson.get_compiler('cpp')
33cereal_dep = dependency('cereal', required: false)
34has_cereal = cxx.has_header_symbol(
35    'cereal/cereal.hpp',
36    'cereal::specialize',
37    dependencies: cereal_dep,
38    required: false)
39if not has_cereal
40    cereal_opts = import('cmake').subproject_options()
41    cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
42    cereal_proj = import('cmake').subproject(
43        'cereal',
44        options: cereal_opts,
45        required: false)
46    assert(cereal_proj.found(), 'cereal is required')
47    cereal_dep = cereal_proj.dependency('cereal')
48endif
49
50systemd_system_unit_dir = dependency('systemd').get_variable(
51          pkgconfig: 'systemdsystemunitdir')
52
53install_subdir('service_files',
54               install_dir : systemd_system_unit_dir,
55               strip_directory : true)
56
57executable(
58    'post-code-manager',
59    'src/main.cpp',
60    'src/post_code.cpp',
61    install: true,
62    dependencies: [
63      sdbusplus,
64      phosphor_dbus_interfaces,
65      phosphor_logging,
66      cereal_dep],
67    include_directories: 'inc')
68