xref: /openbmc/bmcweb/meson.build (revision 04adfbca57e786d4145e71e87885022a94aea013)
1f2caadceSEd Tanousproject(
2f2caadceSEd Tanous    'bmcweb',
3f2caadceSEd Tanous    'cpp',
4af6298daSManojkiran Eda    version: '1.0',
58dc3ddf6SEd Tanous    meson_version: '>=1.3.0',
6af6298daSManojkiran Eda    default_options: [
7cb2ed190SManojkiran Eda        'b_lto_mode=default',
8f523c324SEd Tanous        'b_lto_threads=0',
9f523c324SEd Tanous        'b_lto=true',
10f523c324SEd Tanous        'b_ndebug=if-release',
11f523c324SEd Tanous        'buildtype=debugoptimized',
12f523c324SEd Tanous        'cpp_rtti=false',
13921cfcd1SPatrick Williams        'cpp_std=c++23',
14f523c324SEd Tanous        'warning_level=3',
15f523c324SEd Tanous        'werror=true',
16f2caadceSEd Tanous    ],
17f2caadceSEd Tanous)
18af6298daSManojkiran Eda
19af6298daSManojkiran Eda# Project related links
20af6298daSManojkiran Eda
21af6298daSManojkiran Edaproject_pretty_name = 'bmcweb'
22af6298daSManojkiran Edaproject_url = 'https://github.com/openbmc/' + project_pretty_name
23af6298daSManojkiran Edaproject_issues_url = project_url + '/issues/new'
24af6298daSManojkiran Edasummary('Issues', project_issues_url, section: 'Report Issues')
25af6298daSManojkiran Eda
26af6298daSManojkiran Eda# Validate the c++ Standard
27af6298daSManojkiran Eda
28921cfcd1SPatrick Williamsif get_option('cpp_std') != 'c++23'
29921cfcd1SPatrick Williams    error('This project requires c++23 support')
30af6298daSManojkiran Edaendif
31af6298daSManojkiran Eda
32af6298daSManojkiran Eda# Get compiler and default build type
33af6298daSManojkiran Eda
34af6298daSManojkiran Edacxx = meson.get_compiler('cpp')
35af6298daSManojkiran Edabuild = get_option('buildtype')
36af6298daSManojkiran Edaoptimization = get_option('optimization')
37af6298daSManojkiran Edasummary('Build Type', build, section: 'Build Info')
38af6298daSManojkiran Edasummary('Optimization', optimization, section: 'Build Info')
39af6298daSManojkiran Eda
40af6298daSManojkiran Eda# remove debug information for minsize buildtype
41af6298daSManojkiran Edaif (get_option('buildtype') == 'minsize')
4292e26be5SEd Tanous    add_project_arguments(
4392e26be5SEd Tanous        ['-fdata-sections', '-ffunction-sections'],
4492e26be5SEd Tanous        language: 'cpp',
4592e26be5SEd Tanous    )
46af6298daSManojkiran Eda    add_project_arguments('-DNDEBUG', language: 'cpp')
47af6298daSManojkiran Edaendif
48af6298daSManojkiran Eda
49f8ca6d79SEd Tanousif (get_option('dns-resolver') == 'systemd-dbus')
50f8ca6d79SEd Tanous    add_project_arguments('-DBMCWEB_DBUS_DNS_RESOLVER', language: 'cpp')
51f8ca6d79SEd Tanousendif
52f8ca6d79SEd Tanous
53af6298daSManojkiran Eda# Disable lto when compiling with no optimization
54af6298daSManojkiran Edaif (get_option('optimization') == '0')
55af6298daSManojkiran Eda    add_project_arguments('-fno-lto', language: 'cpp')
56af6298daSManojkiran Eda    message('Disabling lto & its supported features as optimization is disabled')
57af6298daSManojkiran Edaendif
58af6298daSManojkiran Eda
59af6298daSManojkiran Eda# Include Directories
60af6298daSManojkiran Eda
6192e26be5SEd Tanousincdir = include_directories(
6292e26be5SEd Tanous    'include',
6392e26be5SEd Tanous    'redfish-core/include',
6492e26be5SEd Tanous    'redfish-core/lib',
65bd1299b7SAushim Nagarkatti    'http',
66bd1299b7SAushim Nagarkatti)
6792e26be5SEd Tanousincdir_cli = include_directories('http', 'include')
68af6298daSManojkiran Eda
69549bed29SPatrick Williamsif (get_option('tests').allowed())
7025b54dbaSEd Tanous    summary('unittest', 'NA', section: 'Features')
71af6298daSManojkiran Edaendif
72af6298daSManojkiran Eda
73af6298daSManojkiran Eda# Add compiler arguments
74af6298daSManojkiran Eda
75ade3f093SEd Tanousif (cxx.get_id() == 'clang')
76ade3f093SEd Tanous    if (cxx.version().version_compare('<17.0'))
77ade3f093SEd Tanous        error('This project requires clang-17 or higher')
78ade3f093SEd Tanous    endif
79af6298daSManojkiran Eda    add_project_arguments(
80af6298daSManojkiran Eda        '-Weverything',
81ade3f093SEd Tanous        '-Wformat=2',
82af6298daSManojkiran Eda        '-Wno-c++98-compat-pedantic',
83f523c324SEd Tanous        '-Wno-c++98-compat',
8425991f7dSEd Tanous        '-Wno-c++20-extensions',
85f523c324SEd Tanous        '-Wno-documentation-unknown-command',
86f523c324SEd Tanous        '-Wno-documentation',
87af6298daSManojkiran Eda        '-Wno-exit-time-destructors',
88f523c324SEd Tanous        '-Wno-global-constructors',
89f523c324SEd Tanous        '-Wno-newline-eof',
90f523c324SEd Tanous        '-Wno-padded',
91af6298daSManojkiran Eda        '-Wno-shadow',
92af6298daSManojkiran Eda        '-Wno-used-but-marked-unused',
93af6298daSManojkiran Eda        '-Wno-weak-vtables',
94e6801eb4SEd Tanous        '-Wno-switch-enum',
9572b90760SEd Tanous        '-Wno-unused-macros',
964da0490bSEd Tanous        '-Wno-covered-switch-default',
97f88b2170SEd Tanous        '-Wno-disabled-macro-expansion',
98724985ffSEd Tanous        '-Wno-unneeded-internal-declaration',
9960b8de36SEd Tanous        '-Wno-unsafe-buffer-usage-in-container',
100f2caadceSEd Tanous        language: 'cpp',
101f2caadceSEd Tanous    )
102af6298daSManojkiran Edaendif
103af6298daSManojkiran Eda
104ade3f093SEd Tanousif (cxx.get_id() == 'gcc')
105ade3f093SEd Tanous    if (cxx.version().version_compare('<13.0'))
106ade3f093SEd Tanous        error('This project requires gcc-13 or higher')
107ade3f093SEd Tanous    endif
108af6298daSManojkiran Eda
109af6298daSManojkiran Eda    add_project_arguments(
110ade3f093SEd Tanous        '-Wformat=2',
111ade3f093SEd Tanous        '-Wcast-align',
112ade3f093SEd Tanous        '-Wconversion',
113ade3f093SEd Tanous        '-Woverloaded-virtual',
114ade3f093SEd Tanous        '-Wsign-conversion',
115ade3f093SEd Tanous        '-Wunused',
116af6298daSManojkiran Eda        '-Wduplicated-cond',
117af6298daSManojkiran Eda        '-Wduplicated-branches',
118af6298daSManojkiran Eda        '-Wlogical-op',
119af6298daSManojkiran Eda        '-Wnull-dereference',
120079360aeSEd Tanous        '-Wunused-parameter',
121af6298daSManojkiran Eda        '-Wdouble-promotion',
1228a592810SEd Tanous        '-Wshadow',
12330f11eb4SEd Tanous        '-Wno-psabi',
124ade3f093SEd Tanous        '-Wno-attributes',
125f2caadceSEd Tanous        language: 'cpp',
126f2caadceSEd Tanous    )
127c66403c3SEd Tanousendif
128af6298daSManojkiran Eda
129af6298daSManojkiran Edaif (get_option('buildtype') != 'plain')
130af6298daSManojkiran Eda    if (get_option('b_lto') == true and get_option('optimization') != '0')
131af6298daSManojkiran Eda        # Reduce the binary size by removing unnecessary
132af6298daSManojkiran Eda        # dynamic symbol table entries
133af6298daSManojkiran Eda
134af6298daSManojkiran Eda        add_project_arguments(
135f2caadceSEd Tanous            cxx.get_supported_arguments(
136f2caadceSEd Tanous                [
137af6298daSManojkiran Eda                    '-fno-fat-lto-objects',
138af6298daSManojkiran Eda                    '-fvisibility=hidden',
139f2caadceSEd Tanous                    '-fvisibility-inlines-hidden',
140f2caadceSEd Tanous                ],
141f2caadceSEd Tanous            ),
142f2caadceSEd Tanous            language: 'cpp',
143f2caadceSEd Tanous        )
144af6298daSManojkiran Eda
145af6298daSManojkiran Eda        if cxx.has_link_argument('-Wl,--exclude-libs,ALL')
146af6298daSManojkiran Eda            add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp')
147af6298daSManojkiran Eda        endif
148af6298daSManojkiran Eda    endif
149c66403c3SEd Tanousendif
150af6298daSManojkiran Eda# Set Compiler Security flags
151af6298daSManojkiran Eda
152af6298daSManojkiran Edasecurity_flags = [
153af6298daSManojkiran Eda    '-fstack-protector-strong',
154af6298daSManojkiran Eda    '-fPIE',
155af6298daSManojkiran Eda    '-fPIC',
156af6298daSManojkiran Eda    '-D_FORTIFY_SOURCE=2',
157af6298daSManojkiran Eda    '-Wformat',
158f2caadceSEd Tanous    '-Wformat-security',
159af6298daSManojkiran Eda]
160af6298daSManojkiran Eda
161af6298daSManojkiran Eda## Add security flags for builds of type 'release','debugoptimized' and 'minsize'
162af6298daSManojkiran Eda
16392e26be5SEd Tanousif not (get_option('buildtype') == 'plain'
164f2caadceSEd Tanousor get_option('buildtype').startswith('debug')
165f2caadceSEd Tanous)
16692e26be5SEd Tanous    add_project_arguments(
16792e26be5SEd Tanous        cxx.get_supported_arguments([security_flags]),
16892e26be5SEd Tanous        language: 'cpp',
16992e26be5SEd Tanous    )
170af6298daSManojkiran Edaendif
171af6298daSManojkiran Eda
172af6298daSManojkiran Eda# Boost dependency configuration
173af6298daSManojkiran Eda
174af6298daSManojkiran Edaadd_project_arguments(
175f2caadceSEd Tanous    cxx.get_supported_arguments(
176f2caadceSEd Tanous        [
177af6298daSManojkiran Eda            '-DBOOST_ALL_NO_LIB',
17858e42b18SEd Tanous            '-DBOOST_ALLOW_DEPRECATED_HEADERS',
179f523c324SEd Tanous            '-DBOOST_ASIO_DISABLE_THREADS',
180f523c324SEd Tanous            '-DBOOST_ASIO_NO_DEPRECATED',
181f523c324SEd Tanous            '-DBOOST_ASIO_SEPARATE_COMPILATION',
182f523c324SEd Tanous            '-DBOOST_BEAST_SEPARATE_COMPILATION',
1839e710e7fSEd Tanous            '-DBOOST_EXCEPTION_DISABLE',
184f706551dSEd Tanous            '-DBOOST_NO_EXCEPTIONS',
185ab6b6fecSEd Tanous            '-DBOOST_URL_NO_SOURCE_LOCATION',
186f88b2170SEd Tanous            '-DBOOST_SPIRIT_X3_NO_RTTI',
1879e710e7fSEd Tanous            '-DJSON_NOEXCEPTION',
188209aa909SEd Tanous            '-DOPENSSL_NO_FILENAMES',
189f706551dSEd Tanous            '-DSDBUSPLUS_DISABLE_BOOST_COROUTINES',
190f2caadceSEd Tanous        ],
191f2caadceSEd Tanous    ),
192f2caadceSEd Tanous    language: 'cpp',
193f2caadceSEd Tanous)
194af6298daSManojkiran Eda
195af6298daSManojkiran Eda# Find the dependency modules, if not found use meson wrap to get them
196af6298daSManojkiran Eda# automatically during the configure step
197ceb8ddc1SJason M. Billsbmcweb_dependencies = []
198bd1299b7SAushim Nagarkattibmcweb_cli_dependencies = []
199af6298daSManojkiran Eda
2008682c5adSNan Zhoupam = cxx.find_library('pam', required: true)
201af6298daSManojkiran Edaatomic = cxx.find_library('atomic', required: true)
202e7923997SEd Tanousbmcweb_dependencies += [pam, atomic]
203e7923997SEd Tanous
204e7923997SEd Tanousopenssl = dependency('openssl', required: false, version: '>=3.0.0')
205e7923997SEd Tanousif not openssl.found() or get_option('b_sanitize') != 'none'
206e7923997SEd Tanous    openssl_proj = subproject(
207e7923997SEd Tanous        'openssl',
208e7923997SEd Tanous        required: true,
209f2caadceSEd Tanous        default_options: ['warning_level=0', 'werror=false'],
210e7923997SEd Tanous    )
211e7923997SEd Tanous    openssl = openssl_proj.get_variable('openssl_dep')
212e7923997SEd Tanous    openssl = openssl.as_system('system')
213e7923997SEd Tanousendif
214e7923997SEd Tanousbmcweb_dependencies += [openssl]
215af6298daSManojkiran Eda
216fca2cbeaSEd Tanousnghttp2 = dependency('libnghttp2', version: '>=1.52.0', required: false)
217fca2cbeaSEd Tanousif not nghttp2.found()
218fca2cbeaSEd Tanous    cmake = import('cmake')
219fca2cbeaSEd Tanous    opt_var = cmake.subproject_options()
220211cfa49SEd Tanous    opt_var.add_cmake_defines(
22192e26be5SEd Tanous        {'ENABLE_LIB_ONLY': true, 'ENABLE_STATIC_LIB': true},
222211cfa49SEd Tanous    )
223fca2cbeaSEd Tanous    nghttp2_ex = cmake.subproject('nghttp2', options: opt_var)
224211cfa49SEd Tanous    nghttp2 = nghttp2_ex.dependency('nghttp2')
225fca2cbeaSEd Tanousendif
226fca2cbeaSEd Tanousbmcweb_dependencies += nghttp2
227fca2cbeaSEd Tanous
2287bb985eeSEd Tanoussdbusplus = dependency('sdbusplus', required: false, include_type: 'system')
229af6298daSManojkiran Edaif not sdbusplus.found()
230af6298daSManojkiran Eda    sdbusplus_proj = subproject('sdbusplus', required: true)
231af6298daSManojkiran Eda    sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
232af6298daSManojkiran Eda    sdbusplus = sdbusplus.as_system('system')
233af6298daSManojkiran Edaendif
234ceb8ddc1SJason M. Billsbmcweb_dependencies += sdbusplus
235bd1299b7SAushim Nagarkattibmcweb_cli_dependencies += sdbusplus
236bd1299b7SAushim Nagarkatti
237bd1299b7SAushim Nagarkatticli11 = dependency('CLI11', required: false, include_type: 'system')
238bd1299b7SAushim Nagarkattiif not cli11.found()
239bd1299b7SAushim Nagarkatti    cli11_proj = subproject('cli11', required: true)
240bd1299b7SAushim Nagarkatti    cli11 = cli11_proj.get_variable('CLI11_dep')
241bd1299b7SAushim Nagarkatti    cli11 = cli11.as_system('system')
242bd1299b7SAushim Nagarkattiendif
243bd1299b7SAushim Nagarkattibmcweb_cli_dependencies += cli11
244bd1299b7SAushim Nagarkatti
245af6298daSManojkiran Eda
246c9374ff6SEd Tanoustinyxml = dependency(
247c9374ff6SEd Tanous    'tinyxml2',
248565c0911SPatrick Williams    include_type: 'system',
249c9374ff6SEd Tanous    version: '>=9.0.0',
25060e299bdSKonstantin Aladyshev    default_options: ['tests=false'],
251565c0911SPatrick Williams)
252c9374ff6SEd Tanousif not tinyxml.found()
253c9374ff6SEd Tanous    tinyxml_proj = subproject('tinyxml2', required: true)
254c9374ff6SEd Tanous    tinyxml = tinyxml_proj.get_variable('tinyxml_dep')
255c9374ff6SEd Tanous    tinyxml = tinyxml.as_system('system')
256c9374ff6SEd Tanousendif
257ceb8ddc1SJason M. Billsbmcweb_dependencies += tinyxml
258af6298daSManojkiran Eda
259af6298daSManojkiran Edasystemd = dependency('systemd')
260058f54edSPatrick Williamslibsystemd = dependency('libsystemd')
26177dcace6SEd Tanousadd_project_arguments(
26277dcace6SEd Tanous    '-DLIBSYSTEMD_VERSION=' + libsystemd.version(),
26377dcace6SEd Tanous    language: 'cpp',
26477dcace6SEd Tanous)
265055713e4SEd Tanous
266af6298daSManojkiran Edazlib = dependency('zlib')
267058f54edSPatrick Williamsbmcweb_dependencies += [libsystemd, zlib]
268af6298daSManojkiran Eda
26992e26be5SEd Tanousnlohmann_json_dep = dependency(
27092e26be5SEd Tanous    'nlohmann_json',
2710183e476SPatrick Williams    version: '>=3.11.3',
27292e26be5SEd Tanous    include_type: 'system',
27392e26be5SEd Tanous)
274dfd5547bSPatrick Williamsbmcweb_dependencies += nlohmann_json_dep
275af6298daSManojkiran Eda
2762b5b4daeSCarson Labradoboost = dependency(
2772b5b4daeSCarson Labrado    'boost',
27892e26be5SEd Tanous    modules: ['url'],
279619b8609SEd Tanous    version: '>=1.84.0',
2802b5b4daeSCarson Labrado    required: false,
281f2caadceSEd Tanous    include_type: 'system',
2822b5b4daeSCarson Labrado)
28390fcc26aSJayanth Othayoth
28490fcc26aSJayanth Othayoth# Boost version is 1.86 or higher to include the 'process' module
28590fcc26aSJayanth Othayothif boost.version().version_compare('>=1.86.0')
28690fcc26aSJayanth Othayoth    boost = dependency(
28790fcc26aSJayanth Othayoth        'boost',
28890fcc26aSJayanth Othayoth        modules: ['url', 'process'],
28990fcc26aSJayanth Othayoth        version: '>=1.86.0',
29090fcc26aSJayanth Othayoth        required: false,
29190fcc26aSJayanth Othayoth        include_type: 'system',
29290fcc26aSJayanth Othayoth    )
29390fcc26aSJayanth Othayothendif
29490fcc26aSJayanth Othayoth
2956fd29553SEd Tanousif boost.found()
2966fd29553SEd Tanous    bmcweb_dependencies += [boost]
297bd1299b7SAushim Nagarkatti    bmcweb_cli_dependencies += [boost]
2986fd29553SEd Tanouselse
2996fd29553SEd Tanous    cmake = import('cmake')
3006fd29553SEd Tanous    opt = cmake.subproject_options()
301f80a87f2SEd Tanous    boost_libs = [
302f80a87f2SEd Tanous        'asio',
303f80a87f2SEd Tanous        'beast',
304f80a87f2SEd Tanous        'circular_buffer',
305f80a87f2SEd Tanous        'callable_traits',
306f80a87f2SEd Tanous        'headers',
307f80a87f2SEd Tanous        'process',
308f80a87f2SEd Tanous        'type_index',
309f80a87f2SEd Tanous        'url',
310f80a87f2SEd Tanous        'uuid',
311f80a87f2SEd Tanous        'spirit',
312f80a87f2SEd Tanous    ]
313f2caadceSEd Tanous    opt.add_cmake_defines(
314f2caadceSEd Tanous        {
3154ed30a8bSEd Tanous            # 1.86.0 fails this.  Hopefully fixed in 1.86.1
3164ed30a8bSEd Tanous            'CMAKE_CXX_FLAGS': '-Wno-unused-parameter',
317f80a87f2SEd Tanous            'BOOST_INCLUDE_LIBRARIES': ';'.join(boost_libs),
318144983c5SEd Tanous            'BUILD_SHARED_LIBS': 'OFF',
319f2caadceSEd Tanous        },
320f2caadceSEd Tanous    )
321144983c5SEd Tanous
3226fd29553SEd Tanous    boost = cmake.subproject('boost', required: true, options: opt)
323f80a87f2SEd Tanous    foreach boost_lib : boost_libs
324f80a87f2SEd Tanous        boost_lib_instance = boost.dependency('boost_' + boost_lib).as_system()
325f80a87f2SEd Tanous        bmcweb_dependencies += [boost_lib_instance]
326bd1299b7SAushim Nagarkatti        bmcweb_cli_dependencies += [boost_lib_instance]
327f80a87f2SEd Tanous    endforeach
328af6298daSManojkiran Edaendif
329af6298daSManojkiran Eda
3304efe3e0cSPatrick Williamssystemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir')
331af6298daSManojkiran Eda
332af6298daSManojkiran Edabindir = get_option('prefix') + '/' + get_option('bindir')
333bd1299b7SAushim Nagarkattilibexec = get_option('prefix') + '/' + get_option('libexecdir')
334af6298daSManojkiran Eda
335f2caadceSEd Tanoussummary(
336f2caadceSEd Tanous    {
337af6298daSManojkiran Eda        'prefix': get_option('prefix'),
338af6298daSManojkiran Eda        'bindir': bindir,
339f2caadceSEd Tanous        'systemd unit directory': systemd_system_unit_dir,
340f2caadceSEd Tanous    },
341f2caadceSEd Tanous    section: 'Directories',
342f2caadceSEd Tanous)
343af6298daSManojkiran Eda
344a529a6aaSEd Tanoussubdir('static')
345a529a6aaSEd Tanoussubdir('redfish-core')
346af6298daSManojkiran Eda
347307386e8SNan Zhou# Config subdirectory
348307386e8SNan Zhousubdir('config')
349307386e8SNan Zhoubmcweb_dependencies += conf_h_dep
350bd1299b7SAushim Nagarkattibmcweb_cli_dependencies += conf_h_dep
351307386e8SNan Zhou
35202f1cd9bSEd Tanous# Source files
3530ad63df8SNan Zhoufs = import('fs')
354af6298daSManojkiran Eda
3550ad63df8SNan Zhousrcfiles_bmcweb = files(
356724985ffSEd Tanous    'http/mutual_tls.cpp',
357b26ff34dSEd Tanous    'redfish-core/src/dbus_log_watcher.cpp',
35802f1cd9bSEd Tanous    'redfish-core/src/error_messages.cpp',
359b80ba2e4SAlexander Hansen    'redfish-core/src/event_log.cpp',
3602185ddeaSEd Tanous    'redfish-core/src/filesystem_log_watcher.cpp',
36125991f7dSEd Tanous    'redfish-core/src/filter_expr_executor.cpp',
362f88b2170SEd Tanous    'redfish-core/src/filter_expr_printer.cpp',
363a8a5bc1bSEd Tanous    'redfish-core/src/heartbeat_messages.cpp',
364f2caadceSEd Tanous    'redfish-core/src/redfish.cpp',
365d1d411f9SSui Chen    'redfish-core/src/registries.cpp',
366a8a5bc1bSEd Tanous    'redfish-core/src/resource_messages.cpp',
36702c1e29fSAlexander Hansen    'redfish-core/src/subscription.cpp',
368a8a5bc1bSEd Tanous    'redfish-core/src/task_messages.cpp',
369d02aad39SEd Tanous    'redfish-core/src/utils/dbus_utils.cpp',
37002f1cd9bSEd Tanous    'redfish-core/src/utils/json_utils.cpp',
3713cd7072bSEd Tanous    'redfish-core/src/utils/time_utils.cpp',
372f523c324SEd Tanous    'src/boost_asio.cpp',
373f2caadceSEd Tanous    'src/boost_asio_ssl.cpp',
374f523c324SEd Tanous    'src/boost_beast.cpp',
3756384e323SNan Zhou    'src/dbus_singleton.cpp',
37661e349acSEd Tanous    'src/json_html_serializer.cpp',
3772c6ffdb0SEd Tanous    'src/ossl_random.cpp',
378724985ffSEd Tanous    'src/ssl_key_handler.cpp',
379f2caadceSEd Tanous    'src/webserver_run.cpp',
3800ad63df8SNan Zhou)
38102f1cd9bSEd Tanous
38242bbcd87SEd Tanousbmcweblib = static_library(
38342bbcd87SEd Tanous    'bmcweblib',
38442bbcd87SEd Tanous    srcfiles_bmcweb,
38542bbcd87SEd Tanous    include_directories: incdir,
38642bbcd87SEd Tanous    dependencies: bmcweb_dependencies,
38742bbcd87SEd Tanous)
38842bbcd87SEd Tanous
389bd1299b7SAushim Nagarkatti# Generate the bmcwebd daemon
39002f1cd9bSEd Tanousexecutable(
391bd1299b7SAushim Nagarkatti    'bmcwebd',
39242bbcd87SEd Tanous    'src/webserver_main.cpp',
393af6298daSManojkiran Eda    include_directories: incdir,
394ceb8ddc1SJason M. Bills    dependencies: bmcweb_dependencies,
39542bbcd87SEd Tanous    link_with: bmcweblib,
3965e34b67aSEd Tanous    link_args: '-Wl,--gc-sections',
397af6298daSManojkiran Eda    install: true,
39892e26be5SEd Tanous    install_dir: libexec,
399bd1299b7SAushim Nagarkatti)
400bd1299b7SAushim Nagarkatti
401bd1299b7SAushim Nagarkatti# Generate the bmcweb CLI application
402bd1299b7SAushim Nagarkattiexecutable(
403bd1299b7SAushim Nagarkatti    'bmcweb',
404bd1299b7SAushim Nagarkatti    ['src/webserver_cli.cpp', 'src/boost_asio.cpp'],
405bd1299b7SAushim Nagarkatti    include_directories: incdir_cli,
406bd1299b7SAushim Nagarkatti    dependencies: bmcweb_cli_dependencies,
407bd1299b7SAushim Nagarkatti    install: true,
40892e26be5SEd Tanous    install_dir: bindir,
40902f1cd9bSEd Tanous)
41002f1cd9bSEd Tanous
4110ad63df8SNan Zhousrcfiles_unittest = files(
412c33a039bSNan Zhou    'test/http/crow_getroutes_test.cpp',
41352dd6932SEd Tanous    'test/http/http2_connection_test.cpp',
414f2caadceSEd Tanous    'test/http/http_body_test.cpp',
4154fa45dffSEd Tanous    'test/http/http_connection_test.cpp',
4168e3f7032SAbhilash Raju    'test/http/http_response_test.cpp',
417f2caadceSEd Tanous    'test/http/mutual_tls.cpp',
418f2caadceSEd Tanous    'test/http/mutual_tls_meta.cpp',
419f2caadceSEd Tanous    'test/http/parsing_test.cpp',
420f2caadceSEd Tanous    'test/http/router_test.cpp',
421f2caadceSEd Tanous    'test/http/server_sent_event_test.cpp',
422c33a039bSNan Zhou    'test/http/utility_test.cpp',
4232c9efc3cSEd Tanous    'test/http/verb_test.cpp',
424e1452beaSEd Tanous    'test/include/async_resolve_test.cpp',
42511e8f60dSEd Tanous    'test/include/credential_pipe_test.cpp',
426f2caadceSEd Tanous    'test/include/dbus_utility_test.cpp',
427f2caadceSEd Tanous    'test/include/google/google_service_root_test.cpp',
428f2caadceSEd Tanous    'test/include/http_utility_test.cpp',
429f2caadceSEd Tanous    'test/include/human_sort_test.cpp',
430c33a039bSNan Zhou    'test/include/ibm/configfile_test.cpp',
431f2caadceSEd Tanous    'test/include/json_html_serializer.cpp',
432c33a039bSNan Zhou    'test/include/multipart_test.cpp',
433c33a039bSNan Zhou    'test/include/openbmc_dbus_rest_test.cpp',
4342c6ffdb0SEd Tanous    'test/include/ossl_random.cpp',
435099225ccSEd Tanous    'test/include/ssl_key_handler_test.cpp',
436f2caadceSEd Tanous    'test/include/str_utility_test.cpp',
4375494e21dSAlexander Hansen    'test/redfish-core/include/event_log_test.cpp',
438d3a48a14SEd Tanous    'test/redfish-core/include/event_matches_filter_test.cpp',
43925991f7dSEd Tanous    'test/redfish-core/include/filter_expr_executor_test.cpp',
440f88b2170SEd Tanous    'test/redfish-core/include/filter_expr_parser_test.cpp',
44192e26be5SEd Tanous    'test/redfish-core/include/privileges_test.cpp',
4427e8890c5SCarson Labrado    'test/redfish-core/include/redfish_aggregator_test.cpp',
4436e1a52faSEd Tanous    'test/redfish-core/include/redfish_test.cpp',
444c33a039bSNan Zhou    'test/redfish-core/include/registries_test.cpp',
445*04adfbcaSEd Tanous    'test/redfish-core/include/submit_test_event_test.cpp',
446d02aad39SEd Tanous    'test/redfish-core/include/utils/dbus_utils.cpp',
447f2caadceSEd Tanous    'test/redfish-core/include/utils/hex_utils_test.cpp',
448c33a039bSNan Zhou    'test/redfish-core/include/utils/ip_utils_test.cpp',
449c33a039bSNan Zhou    'test/redfish-core/include/utils/json_utils_test.cpp',
450c33a039bSNan Zhou    'test/redfish-core/include/utils/query_param_test.cpp',
4511516c21bSJanet Adkins    'test/redfish-core/include/utils/sensor_utils_test.cpp',
452c33a039bSNan Zhou    'test/redfish-core/include/utils/stl_utils_test.cpp',
453c33a039bSNan Zhou    'test/redfish-core/include/utils/time_utils_test.cpp',
454c33a039bSNan Zhou    'test/redfish-core/lib/chassis_test.cpp',
4556e1a52faSEd Tanous    'test/redfish-core/lib/ethernet_test.cpp',
456c33a039bSNan Zhou    'test/redfish-core/lib/log_services_dump_test.cpp',
457e610b316SJagpal Singh Gill    'test/redfish-core/lib/manager_diagnostic_data_test.cpp',
458090ab8e1SEd Tanous    'test/redfish-core/lib/metadata_test.cpp',
459f2caadceSEd Tanous    'test/redfish-core/lib/power_subsystem_test.cpp',
460f2caadceSEd Tanous    'test/redfish-core/lib/service_root_test.cpp',
461f2caadceSEd Tanous    'test/redfish-core/lib/system_test.cpp',
4628d2f868cSEd Tanous    'test/redfish-core/lib/systems_logservices_postcode.cpp',
463f2caadceSEd Tanous    'test/redfish-core/lib/thermal_subsystem_test.cpp',
464f2caadceSEd Tanous    'test/redfish-core/lib/update_service_test.cpp',
4650ad63df8SNan Zhou)
466af6298daSManojkiran Eda
467549bed29SPatrick Williamsif (get_option('tests').allowed())
46877dcace6SEd Tanous    gtest = dependency(
46977dcace6SEd Tanous        'gtest_main',
47077dcace6SEd Tanous        main: true,
47177dcace6SEd Tanous        version: '>=1.15.0',
47277dcace6SEd Tanous        required: true,
47377dcace6SEd Tanous    )
47477dcace6SEd Tanous    gmock = dependency('gmock', required: true)
47577dcace6SEd Tanous    gtestlib = static_library('gtestlib', dependencies: [gtest, gmock])
47677dcace6SEd Tanous    gtestdep = declare_dependency(
47777dcace6SEd Tanous        link_with: gtestlib,
47877dcace6SEd Tanous        dependencies: [
47977dcace6SEd Tanous            gtest.partial_dependency(includes: true),
48077dcace6SEd Tanous            gmock.partial_dependency(includes: true),
48177dcace6SEd Tanous        ],
48277dcace6SEd Tanous    )
48302f1cd9bSEd Tanous    # generate the test executable
4840ad63df8SNan Zhou    foreach test_src : srcfiles_unittest
4850ad63df8SNan Zhou        test_bin = executable(
4860ad63df8SNan Zhou            fs.stem(test_src),
48742bbcd87SEd Tanous            test_src,
48842bbcd87SEd Tanous            link_with: bmcweblib,
489af6298daSManojkiran Eda            include_directories: incdir,
490af6298daSManojkiran Eda            install_dir: bindir,
49177dcace6SEd Tanous            dependencies: bmcweb_dependencies + [gtestdep],
49202f1cd9bSEd Tanous        )
49377dcace6SEd Tanous        test(fs.stem(test_src), test_bin, protocol: 'gtest')
4940ad63df8SNan Zhou    endforeach
495af6298daSManojkiran Edaendif
496