xref: /openbmc/bmcweb/meson.build (revision 2185ddeac3ed0c49da6399af635f31544e382373)
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',
99f2caadceSEd Tanous        language: 'cpp',
100f2caadceSEd Tanous    )
101af6298daSManojkiran Edaendif
102af6298daSManojkiran Eda
103ade3f093SEd Tanousif (cxx.get_id() == 'gcc')
104ade3f093SEd Tanous    if (cxx.version().version_compare('<13.0'))
105ade3f093SEd Tanous        error('This project requires gcc-13 or higher')
106ade3f093SEd Tanous    endif
107af6298daSManojkiran Eda
108af6298daSManojkiran Eda    add_project_arguments(
109ade3f093SEd Tanous        '-Wformat=2',
110ade3f093SEd Tanous        '-Wcast-align',
111ade3f093SEd Tanous        '-Wconversion',
112ade3f093SEd Tanous        '-Woverloaded-virtual',
113ade3f093SEd Tanous        '-Wsign-conversion',
114ade3f093SEd Tanous        '-Wunused',
115af6298daSManojkiran Eda        '-Wduplicated-cond',
116af6298daSManojkiran Eda        '-Wduplicated-branches',
117af6298daSManojkiran Eda        '-Wlogical-op',
118af6298daSManojkiran Eda        '-Wnull-dereference',
119079360aeSEd Tanous        '-Wunused-parameter',
120af6298daSManojkiran Eda        '-Wdouble-promotion',
1218a592810SEd Tanous        '-Wshadow',
12230f11eb4SEd Tanous        '-Wno-psabi',
123ade3f093SEd Tanous        '-Wno-attributes',
124f2caadceSEd Tanous        language: 'cpp',
125f2caadceSEd Tanous    )
126c66403c3SEd Tanousendif
127af6298daSManojkiran Eda
128af6298daSManojkiran Edaif (get_option('buildtype') != 'plain')
129af6298daSManojkiran Eda    if (get_option('b_lto') == true and get_option('optimization') != '0')
130af6298daSManojkiran Eda        # Reduce the binary size by removing unnecessary
131af6298daSManojkiran Eda        # dynamic symbol table entries
132af6298daSManojkiran Eda
133af6298daSManojkiran Eda        add_project_arguments(
134f2caadceSEd Tanous            cxx.get_supported_arguments(
135f2caadceSEd Tanous                [
136af6298daSManojkiran Eda                    '-fno-fat-lto-objects',
137af6298daSManojkiran Eda                    '-fvisibility=hidden',
138f2caadceSEd Tanous                    '-fvisibility-inlines-hidden',
139f2caadceSEd Tanous                ],
140f2caadceSEd Tanous            ),
141f2caadceSEd Tanous            language: 'cpp',
142f2caadceSEd Tanous        )
143af6298daSManojkiran Eda
144af6298daSManojkiran Eda        if cxx.has_link_argument('-Wl,--exclude-libs,ALL')
145af6298daSManojkiran Eda            add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp')
146af6298daSManojkiran Eda        endif
147af6298daSManojkiran Eda    endif
148c66403c3SEd Tanousendif
149af6298daSManojkiran Eda# Set Compiler Security flags
150af6298daSManojkiran Eda
151af6298daSManojkiran Edasecurity_flags = [
152af6298daSManojkiran Eda    '-fstack-protector-strong',
153af6298daSManojkiran Eda    '-fPIE',
154af6298daSManojkiran Eda    '-fPIC',
155af6298daSManojkiran Eda    '-D_FORTIFY_SOURCE=2',
156af6298daSManojkiran Eda    '-Wformat',
157f2caadceSEd Tanous    '-Wformat-security',
158af6298daSManojkiran Eda]
159af6298daSManojkiran Eda
160af6298daSManojkiran Eda## Add security flags for builds of type 'release','debugoptimized' and 'minsize'
161af6298daSManojkiran Eda
16292e26be5SEd Tanousif not (get_option('buildtype') == 'plain'
163f2caadceSEd Tanousor get_option('buildtype').startswith('debug')
164f2caadceSEd Tanous)
16592e26be5SEd Tanous    add_project_arguments(
16692e26be5SEd Tanous        cxx.get_supported_arguments([security_flags]),
16792e26be5SEd Tanous        language: 'cpp',
16892e26be5SEd Tanous    )
169af6298daSManojkiran Edaendif
170af6298daSManojkiran Eda
171af6298daSManojkiran Eda# Boost dependency configuration
172af6298daSManojkiran Eda
173af6298daSManojkiran Edaadd_project_arguments(
174f2caadceSEd Tanous    cxx.get_supported_arguments(
175f2caadceSEd Tanous        [
176af6298daSManojkiran Eda            '-DBOOST_ALL_NO_LIB',
17758e42b18SEd Tanous            '-DBOOST_ALLOW_DEPRECATED_HEADERS',
178f523c324SEd Tanous            '-DBOOST_ASIO_DISABLE_THREADS',
179f523c324SEd Tanous            '-DBOOST_ASIO_NO_DEPRECATED',
180f523c324SEd Tanous            '-DBOOST_ASIO_SEPARATE_COMPILATION',
181f523c324SEd Tanous            '-DBOOST_BEAST_SEPARATE_COMPILATION',
1829e710e7fSEd Tanous            '-DBOOST_EXCEPTION_DISABLE',
183f706551dSEd Tanous            '-DBOOST_NO_EXCEPTIONS',
184ab6b6fecSEd Tanous            '-DBOOST_URL_NO_SOURCE_LOCATION',
185f88b2170SEd Tanous            '-DBOOST_SPIRIT_X3_NO_RTTI',
1869e710e7fSEd Tanous            '-DJSON_NOEXCEPTION',
187209aa909SEd Tanous            '-DOPENSSL_NO_FILENAMES',
188f706551dSEd Tanous            '-DSDBUSPLUS_DISABLE_BOOST_COROUTINES',
189f2caadceSEd Tanous        ],
190f2caadceSEd Tanous    ),
191f2caadceSEd Tanous    language: 'cpp',
192f2caadceSEd Tanous)
193af6298daSManojkiran Eda
194af6298daSManojkiran Eda# Find the dependency modules, if not found use meson wrap to get them
195af6298daSManojkiran Eda# automatically during the configure step
196ceb8ddc1SJason M. Billsbmcweb_dependencies = []
197bd1299b7SAushim Nagarkattibmcweb_cli_dependencies = []
198af6298daSManojkiran Eda
1998682c5adSNan Zhoupam = cxx.find_library('pam', required: true)
200af6298daSManojkiran Edaatomic = cxx.find_library('atomic', required: true)
201e7923997SEd Tanousbmcweb_dependencies += [pam, atomic]
202e7923997SEd Tanous
203e7923997SEd Tanousopenssl = dependency('openssl', required: false, version: '>=3.0.0')
204e7923997SEd Tanousif not openssl.found() or get_option('b_sanitize') != 'none'
205e7923997SEd Tanous    openssl_proj = subproject(
206e7923997SEd Tanous        'openssl',
207e7923997SEd Tanous        required: true,
208f2caadceSEd Tanous        default_options: ['warning_level=0', 'werror=false'],
209e7923997SEd Tanous    )
210e7923997SEd Tanous    openssl = openssl_proj.get_variable('openssl_dep')
211e7923997SEd Tanous    openssl = openssl.as_system('system')
212e7923997SEd Tanousendif
213e7923997SEd Tanousbmcweb_dependencies += [openssl]
214af6298daSManojkiran Eda
215fca2cbeaSEd Tanousnghttp2 = dependency('libnghttp2', version: '>=1.52.0', required: false)
216fca2cbeaSEd Tanousif not nghttp2.found()
217fca2cbeaSEd Tanous    cmake = import('cmake')
218fca2cbeaSEd Tanous    opt_var = cmake.subproject_options()
219211cfa49SEd Tanous    opt_var.add_cmake_defines(
22092e26be5SEd Tanous        {'ENABLE_LIB_ONLY': true, 'ENABLE_STATIC_LIB': true},
221211cfa49SEd Tanous    )
222fca2cbeaSEd Tanous    nghttp2_ex = cmake.subproject('nghttp2', options: opt_var)
223211cfa49SEd Tanous    nghttp2 = nghttp2_ex.dependency('nghttp2')
224fca2cbeaSEd Tanousendif
225fca2cbeaSEd Tanousbmcweb_dependencies += nghttp2
226fca2cbeaSEd Tanous
2277bb985eeSEd Tanoussdbusplus = dependency('sdbusplus', required: false, include_type: 'system')
228af6298daSManojkiran Edaif not sdbusplus.found()
229af6298daSManojkiran Eda    sdbusplus_proj = subproject('sdbusplus', required: true)
230af6298daSManojkiran Eda    sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
231af6298daSManojkiran Eda    sdbusplus = sdbusplus.as_system('system')
232af6298daSManojkiran Edaendif
233ceb8ddc1SJason M. Billsbmcweb_dependencies += sdbusplus
234bd1299b7SAushim Nagarkattibmcweb_cli_dependencies += sdbusplus
235bd1299b7SAushim Nagarkatti
236bd1299b7SAushim Nagarkatticli11 = dependency('CLI11', required: false, include_type: 'system')
237bd1299b7SAushim Nagarkattiif not cli11.found()
238bd1299b7SAushim Nagarkatti    cli11_proj = subproject('cli11', required: true)
239bd1299b7SAushim Nagarkatti    cli11 = cli11_proj.get_variable('CLI11_dep')
240bd1299b7SAushim Nagarkatti    cli11 = cli11.as_system('system')
241bd1299b7SAushim Nagarkattiendif
242bd1299b7SAushim Nagarkattibmcweb_cli_dependencies += cli11
243bd1299b7SAushim Nagarkatti
244af6298daSManojkiran Eda
245c9374ff6SEd Tanoustinyxml = dependency(
246c9374ff6SEd Tanous    'tinyxml2',
247565c0911SPatrick Williams    include_type: 'system',
248c9374ff6SEd Tanous    version: '>=9.0.0',
24960e299bdSKonstantin Aladyshev    default_options: ['tests=false'],
250565c0911SPatrick Williams)
251c9374ff6SEd Tanousif not tinyxml.found()
252c9374ff6SEd Tanous    tinyxml_proj = subproject('tinyxml2', required: true)
253c9374ff6SEd Tanous    tinyxml = tinyxml_proj.get_variable('tinyxml_dep')
254c9374ff6SEd Tanous    tinyxml = tinyxml.as_system('system')
255c9374ff6SEd Tanousendif
256ceb8ddc1SJason M. Billsbmcweb_dependencies += tinyxml
257af6298daSManojkiran Eda
258af6298daSManojkiran Edasystemd = dependency('systemd')
259058f54edSPatrick Williamslibsystemd = dependency('libsystemd')
26077dcace6SEd Tanousadd_project_arguments(
26177dcace6SEd Tanous    '-DLIBSYSTEMD_VERSION=' + libsystemd.version(),
26277dcace6SEd Tanous    language: 'cpp',
26377dcace6SEd Tanous)
264055713e4SEd Tanous
265af6298daSManojkiran Edazlib = dependency('zlib')
266058f54edSPatrick Williamsbmcweb_dependencies += [libsystemd, zlib]
267af6298daSManojkiran Eda
26892e26be5SEd Tanousnlohmann_json_dep = dependency(
26992e26be5SEd Tanous    'nlohmann_json',
2700183e476SPatrick Williams    version: '>=3.11.3',
27192e26be5SEd Tanous    include_type: 'system',
27292e26be5SEd Tanous)
273dfd5547bSPatrick Williamsbmcweb_dependencies += nlohmann_json_dep
274af6298daSManojkiran Eda
2752b5b4daeSCarson Labradoboost = dependency(
2762b5b4daeSCarson Labrado    'boost',
27792e26be5SEd Tanous    modules: ['url'],
278619b8609SEd Tanous    version: '>=1.84.0',
2792b5b4daeSCarson Labrado    required: false,
280f2caadceSEd Tanous    include_type: 'system',
2812b5b4daeSCarson Labrado)
2826fd29553SEd Tanousif boost.found()
2836fd29553SEd Tanous    bmcweb_dependencies += [boost]
284bd1299b7SAushim Nagarkatti    bmcweb_cli_dependencies += [boost]
2856fd29553SEd Tanouselse
2866fd29553SEd Tanous    cmake = import('cmake')
2876fd29553SEd Tanous    opt = cmake.subproject_options()
288f80a87f2SEd Tanous    boost_libs = [
289f80a87f2SEd Tanous        'asio',
290f80a87f2SEd Tanous        'beast',
291f80a87f2SEd Tanous        'circular_buffer',
292f80a87f2SEd Tanous        'callable_traits',
293f80a87f2SEd Tanous        'headers',
294f80a87f2SEd Tanous        'process',
295f80a87f2SEd Tanous        'type_index',
296f80a87f2SEd Tanous        'url',
297f80a87f2SEd Tanous        'uuid',
298f80a87f2SEd Tanous        'spirit',
299f80a87f2SEd Tanous    ]
300f2caadceSEd Tanous    opt.add_cmake_defines(
301f2caadceSEd Tanous        {
3024ed30a8bSEd Tanous            # 1.86.0 fails this.  Hopefully fixed in 1.86.1
3034ed30a8bSEd Tanous            'CMAKE_CXX_FLAGS': '-Wno-unused-parameter',
304f80a87f2SEd Tanous            'BOOST_INCLUDE_LIBRARIES': ';'.join(boost_libs),
305144983c5SEd Tanous            'BUILD_SHARED_LIBS': 'OFF',
306f2caadceSEd Tanous        },
307f2caadceSEd Tanous    )
308144983c5SEd Tanous
3096fd29553SEd Tanous    boost = cmake.subproject('boost', required: true, options: opt)
310f80a87f2SEd Tanous    foreach boost_lib : boost_libs
311f80a87f2SEd Tanous        boost_lib_instance = boost.dependency('boost_' + boost_lib).as_system()
312f80a87f2SEd Tanous        bmcweb_dependencies += [boost_lib_instance]
313bd1299b7SAushim Nagarkatti        bmcweb_cli_dependencies += [boost_lib_instance]
314f80a87f2SEd Tanous    endforeach
315af6298daSManojkiran Edaendif
316af6298daSManojkiran Eda
3174efe3e0cSPatrick Williamssystemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir')
318af6298daSManojkiran Eda
319af6298daSManojkiran Edabindir = get_option('prefix') + '/' + get_option('bindir')
320bd1299b7SAushim Nagarkattilibexec = get_option('prefix') + '/' + get_option('libexecdir')
321af6298daSManojkiran Eda
322f2caadceSEd Tanoussummary(
323f2caadceSEd Tanous    {
324af6298daSManojkiran Eda        'prefix': get_option('prefix'),
325af6298daSManojkiran Eda        'bindir': bindir,
326f2caadceSEd Tanous        'systemd unit directory': systemd_system_unit_dir,
327f2caadceSEd Tanous    },
328f2caadceSEd Tanous    section: 'Directories',
329f2caadceSEd Tanous)
330af6298daSManojkiran Eda
331a529a6aaSEd Tanoussubdir('static')
332a529a6aaSEd Tanoussubdir('redfish-core')
333af6298daSManojkiran Eda
334307386e8SNan Zhou# Config subdirectory
335307386e8SNan Zhousubdir('config')
336307386e8SNan Zhoubmcweb_dependencies += conf_h_dep
337bd1299b7SAushim Nagarkattibmcweb_cli_dependencies += conf_h_dep
338307386e8SNan Zhou
33902f1cd9bSEd Tanous# Source files
3400ad63df8SNan Zhoufs = import('fs')
341af6298daSManojkiran Eda
3420ad63df8SNan Zhousrcfiles_bmcweb = files(
343724985ffSEd Tanous    'http/mutual_tls.cpp',
34402f1cd9bSEd Tanous    'redfish-core/src/error_messages.cpp',
345b80ba2e4SAlexander Hansen    'redfish-core/src/event_log.cpp',
346*2185ddeaSEd Tanous    'redfish-core/src/filesystem_log_watcher.cpp',
34725991f7dSEd Tanous    'redfish-core/src/filter_expr_executor.cpp',
348f88b2170SEd Tanous    'redfish-core/src/filter_expr_printer.cpp',
349f2caadceSEd Tanous    'redfish-core/src/redfish.cpp',
350d1d411f9SSui Chen    'redfish-core/src/registries.cpp',
35102c1e29fSAlexander Hansen    'redfish-core/src/subscription.cpp',
352d02aad39SEd Tanous    'redfish-core/src/utils/dbus_utils.cpp',
35302f1cd9bSEd Tanous    'redfish-core/src/utils/json_utils.cpp',
3543cd7072bSEd Tanous    'redfish-core/src/utils/time_utils.cpp',
355f523c324SEd Tanous    'src/boost_asio.cpp',
356f2caadceSEd Tanous    'src/boost_asio_ssl.cpp',
357f523c324SEd Tanous    'src/boost_beast.cpp',
3586384e323SNan Zhou    'src/dbus_singleton.cpp',
35961e349acSEd Tanous    'src/json_html_serializer.cpp',
3602c6ffdb0SEd Tanous    'src/ossl_random.cpp',
361724985ffSEd Tanous    'src/ssl_key_handler.cpp',
362f2caadceSEd Tanous    'src/webserver_run.cpp',
3630ad63df8SNan Zhou)
36402f1cd9bSEd Tanous
36542bbcd87SEd Tanousbmcweblib = static_library(
36642bbcd87SEd Tanous    'bmcweblib',
36742bbcd87SEd Tanous    srcfiles_bmcweb,
36842bbcd87SEd Tanous    include_directories: incdir,
36942bbcd87SEd Tanous    dependencies: bmcweb_dependencies,
37042bbcd87SEd Tanous)
37142bbcd87SEd Tanous
372bd1299b7SAushim Nagarkatti# Generate the bmcwebd daemon
37302f1cd9bSEd Tanousexecutable(
374bd1299b7SAushim Nagarkatti    'bmcwebd',
37542bbcd87SEd Tanous    'src/webserver_main.cpp',
376af6298daSManojkiran Eda    include_directories: incdir,
377ceb8ddc1SJason M. Bills    dependencies: bmcweb_dependencies,
37842bbcd87SEd Tanous    link_with: bmcweblib,
3795e34b67aSEd Tanous    link_args: '-Wl,--gc-sections',
380af6298daSManojkiran Eda    install: true,
38192e26be5SEd Tanous    install_dir: libexec,
382bd1299b7SAushim Nagarkatti)
383bd1299b7SAushim Nagarkatti
384bd1299b7SAushim Nagarkatti# Generate the bmcweb CLI application
385bd1299b7SAushim Nagarkattiexecutable(
386bd1299b7SAushim Nagarkatti    'bmcweb',
387bd1299b7SAushim Nagarkatti    ['src/webserver_cli.cpp', 'src/boost_asio.cpp'],
388bd1299b7SAushim Nagarkatti    include_directories: incdir_cli,
389bd1299b7SAushim Nagarkatti    dependencies: bmcweb_cli_dependencies,
390bd1299b7SAushim Nagarkatti    install: true,
39192e26be5SEd Tanous    install_dir: bindir,
39202f1cd9bSEd Tanous)
39302f1cd9bSEd Tanous
3940ad63df8SNan Zhousrcfiles_unittest = files(
395c33a039bSNan Zhou    'test/http/crow_getroutes_test.cpp',
39652dd6932SEd Tanous    'test/http/http2_connection_test.cpp',
397f2caadceSEd Tanous    'test/http/http_body_test.cpp',
3984fa45dffSEd Tanous    'test/http/http_connection_test.cpp',
3998e3f7032SAbhilash Raju    'test/http/http_response_test.cpp',
400f2caadceSEd Tanous    'test/http/mutual_tls.cpp',
401f2caadceSEd Tanous    'test/http/mutual_tls_meta.cpp',
402f2caadceSEd Tanous    'test/http/parsing_test.cpp',
403f2caadceSEd Tanous    'test/http/router_test.cpp',
404f2caadceSEd Tanous    'test/http/server_sent_event_test.cpp',
405c33a039bSNan Zhou    'test/http/utility_test.cpp',
4062c9efc3cSEd Tanous    'test/http/verb_test.cpp',
407e1452beaSEd Tanous    'test/include/async_resolve_test.cpp',
40811e8f60dSEd Tanous    'test/include/credential_pipe_test.cpp',
409f2caadceSEd Tanous    'test/include/dbus_utility_test.cpp',
410f2caadceSEd Tanous    'test/include/google/google_service_root_test.cpp',
411f2caadceSEd Tanous    'test/include/http_utility_test.cpp',
412f2caadceSEd Tanous    'test/include/human_sort_test.cpp',
413c33a039bSNan Zhou    'test/include/ibm/configfile_test.cpp',
414f2caadceSEd Tanous    'test/include/json_html_serializer.cpp',
415c33a039bSNan Zhou    'test/include/multipart_test.cpp',
416c33a039bSNan Zhou    'test/include/openbmc_dbus_rest_test.cpp',
4172c6ffdb0SEd Tanous    'test/include/ossl_random.cpp',
418099225ccSEd Tanous    'test/include/ssl_key_handler_test.cpp',
419f2caadceSEd Tanous    'test/include/str_utility_test.cpp',
4205494e21dSAlexander Hansen    'test/redfish-core/include/event_log_test.cpp',
421d3a48a14SEd Tanous    'test/redfish-core/include/event_matches_filter_test.cpp',
42225991f7dSEd Tanous    'test/redfish-core/include/filter_expr_executor_test.cpp',
423f88b2170SEd Tanous    'test/redfish-core/include/filter_expr_parser_test.cpp',
42492e26be5SEd Tanous    'test/redfish-core/include/privileges_test.cpp',
4257e8890c5SCarson Labrado    'test/redfish-core/include/redfish_aggregator_test.cpp',
426c33a039bSNan Zhou    'test/redfish-core/include/registries_test.cpp',
427d02aad39SEd Tanous    'test/redfish-core/include/utils/dbus_utils.cpp',
428f2caadceSEd Tanous    'test/redfish-core/include/utils/hex_utils_test.cpp',
429c33a039bSNan Zhou    'test/redfish-core/include/utils/ip_utils_test.cpp',
430c33a039bSNan Zhou    'test/redfish-core/include/utils/json_utils_test.cpp',
43115b6f9f9SEd Tanous    'test/redfish-core/include/redfish_test.cpp',
432c33a039bSNan Zhou    'test/redfish-core/include/utils/query_param_test.cpp',
4331516c21bSJanet Adkins    'test/redfish-core/include/utils/sensor_utils_test.cpp',
434c33a039bSNan Zhou    'test/redfish-core/include/utils/stl_utils_test.cpp',
435c33a039bSNan Zhou    'test/redfish-core/include/utils/time_utils_test.cpp',
436c33a039bSNan Zhou    'test/redfish-core/lib/chassis_test.cpp',
437c33a039bSNan Zhou    'test/redfish-core/lib/log_services_dump_test.cpp',
438e610b316SJagpal Singh Gill    'test/redfish-core/lib/manager_diagnostic_data_test.cpp',
4398d2f868cSEd Tanous    'test/redfish-core/lib/manager_logservices_journal_test.cpp',
440090ab8e1SEd Tanous    'test/redfish-core/lib/metadata_test.cpp',
441f2caadceSEd Tanous    'test/redfish-core/lib/power_subsystem_test.cpp',
442f2caadceSEd Tanous    'test/redfish-core/lib/service_root_test.cpp',
443f2caadceSEd Tanous    'test/redfish-core/lib/system_test.cpp',
4448d2f868cSEd Tanous    'test/redfish-core/lib/systems_logservices_postcode.cpp',
445f2caadceSEd Tanous    'test/redfish-core/lib/thermal_subsystem_test.cpp',
446f2caadceSEd Tanous    'test/redfish-core/lib/update_service_test.cpp',
4470ad63df8SNan Zhou)
448af6298daSManojkiran Eda
449549bed29SPatrick Williamsif (get_option('tests').allowed())
45077dcace6SEd Tanous    gtest = dependency(
45177dcace6SEd Tanous        'gtest_main',
45277dcace6SEd Tanous        main: true,
45377dcace6SEd Tanous        version: '>=1.15.0',
45477dcace6SEd Tanous        required: true,
45577dcace6SEd Tanous    )
45677dcace6SEd Tanous    gmock = dependency('gmock', required: true)
45777dcace6SEd Tanous    gtestlib = static_library('gtestlib', dependencies: [gtest, gmock])
45877dcace6SEd Tanous    gtestdep = declare_dependency(
45977dcace6SEd Tanous        link_with: gtestlib,
46077dcace6SEd Tanous        dependencies: [
46177dcace6SEd Tanous            gtest.partial_dependency(includes: true),
46277dcace6SEd Tanous            gmock.partial_dependency(includes: true),
46377dcace6SEd Tanous        ],
46477dcace6SEd Tanous    )
46502f1cd9bSEd Tanous    # generate the test executable
4660ad63df8SNan Zhou    foreach test_src : srcfiles_unittest
4670ad63df8SNan Zhou        test_bin = executable(
4680ad63df8SNan Zhou            fs.stem(test_src),
46942bbcd87SEd Tanous            test_src,
47042bbcd87SEd Tanous            link_with: bmcweblib,
471af6298daSManojkiran Eda            include_directories: incdir,
472af6298daSManojkiran Eda            install_dir: bindir,
47377dcace6SEd Tanous            dependencies: bmcweb_dependencies + [gtestdep],
47402f1cd9bSEd Tanous        )
47577dcace6SEd Tanous        test(fs.stem(test_src), test_bin, protocol: 'gtest')
4760ad63df8SNan Zhou    endforeach
477af6298daSManojkiran Edaendif
478