1project(
2    'phosphor-certificate-manager',
3    'cpp',
4    default_options: [
5        'buildtype=debugoptimized',
6        'cpp_std=c++23',
7        'warning_level=3',
8        'werror=true',
9    ],
10    meson_version: '>=1.1.1',
11)
12
13cpp = meson.get_compiler('cpp')
14
15sdbusplus_dep = dependency('sdbusplus')
16sdeventplus_dep = dependency('sdeventplus')
17phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
18phosphor_logging_dep = dependency('phosphor-logging')
19
20cli11_dep = dependency('cli11', required: false)
21has_cli11 = meson.get_compiler('cpp').has_header_symbol(
22  'CLI/CLI.hpp',
23  'CLI::App',
24  dependencies: cli11_dep,
25  required: false)
26if not has_cli11
27  cli11_proj = subproject('cli11', required: false)
28  assert(cli11_proj.found(), 'CLI11 is required')
29  cli11_dep = cli11_proj.get_variable('CLI11_dep')
30endif
31
32systemd_dep = dependency('systemd')
33openssl_dep = dependency('openssl')
34
35config_data = configuration_data()
36config_data.set(
37    'authority_limit',
38     get_option('authority-limit')
39)
40config_data.set(
41    'authorities_list_name',
42     get_option('authorities-list-name')
43)
44
45if not get_option('allow-expired').disabled()
46  config_data.set('allow_expired', 'true')
47else
48  config_data.set('allow_expired', 'false')
49endif
50
51configure_file(
52    input: 'config.h.in',
53    output: 'config.h',
54    configuration: config_data
55)
56
57phosphor_certificate_deps = [
58    openssl_dep,
59    phosphor_dbus_interfaces_dep,
60    phosphor_logging_dep,
61    sdbusplus_dep,
62    sdeventplus_dep,
63    cli11_dep,
64]
65
66cert_manager_lib = static_library(
67    'phosphor-certificate-manager',
68    [
69        'argument.cpp',
70        'certificate.cpp',
71        'certs_manager.cpp',
72        'csr.cpp',
73        'watch.cpp',
74        'x509_utils.cpp',
75    ],
76    dependencies: phosphor_certificate_deps,
77)
78
79cert_manager_dep = declare_dependency(
80    link_with: cert_manager_lib,
81    dependencies: phosphor_certificate_deps
82)
83
84executable(
85    'phosphor-certificate-manager',
86    'mainapp.cpp',
87    dependencies: cert_manager_dep,
88    install: true,
89)
90
91if not get_option('ca-cert-extension').disabled()
92  subdir('bmc-vmi-ca')
93endif
94
95subdir('dist')
96
97if not get_option('tests').disabled()
98    subdir('test')
99endif
100
101