xref: /openbmc/bmcweb/meson.build (revision 1aa0c2b84be62a20d8c37a11ad877e0a8a48c69d)
1af6298daSManojkiran Edaproject('bmcweb', 'cpp',
2af6298daSManojkiran Eda        version : '1.0',
36107da1eSEd Tanous        meson_version: '>=0.63.0',
4af6298daSManojkiran Eda        default_options: [
5cb2ed190SManojkiran Eda            'b_lto_mode=default',
6f523c324SEd Tanous            'b_lto_threads=0',
7f523c324SEd Tanous            'b_lto=true',
8f523c324SEd Tanous            'b_ndebug=if-release',
9f523c324SEd Tanous            'buildtype=debugoptimized',
10f523c324SEd Tanous            'cpp_rtti=false',
11f523c324SEd Tanous            'cpp_std=c++20',
12f523c324SEd Tanous            'warning_level=3',
13f523c324SEd Tanous            'werror=true',
14af6298daSManojkiran Eda           ])
15af6298daSManojkiran Eda
16af6298daSManojkiran Eda# Project related links
17af6298daSManojkiran Eda
18af6298daSManojkiran Edaproject_pretty_name = 'bmcweb'
19af6298daSManojkiran Edaproject_url = 'https://github.com/openbmc/' + project_pretty_name
20af6298daSManojkiran Edaproject_issues_url = project_url + '/issues/new'
21af6298daSManojkiran Edasummary('Issues',project_issues_url, section: 'Report Issues')
22af6298daSManojkiran Eda
23af6298daSManojkiran Eda# Validate the c++ Standard
24af6298daSManojkiran Eda
25c52ee72bSPatrick Williamsif get_option('cpp_std') != 'c++20'
26c52ee72bSPatrick Williams    error('This project requires c++20 support')
27af6298daSManojkiran Edaendif
28af6298daSManojkiran Eda
29af6298daSManojkiran Eda# Get compiler and default build type
30af6298daSManojkiran Eda
31af6298daSManojkiran Edacxx = meson.get_compiler('cpp')
32af6298daSManojkiran Edabuild = get_option('buildtype')
33af6298daSManojkiran Edaoptimization = get_option('optimization')
34af6298daSManojkiran Edasummary('Build Type',build, section : 'Build Info')
35af6298daSManojkiran Edasummary('Optimization',optimization, section : 'Build Info')
36af6298daSManojkiran Eda
375e34b67aSEd Tanous
38af6298daSManojkiran Eda# remove debug information for minsize buildtype
39af6298daSManojkiran Edaif(get_option('buildtype') == 'minsize')
405e34b67aSEd Tanous  add_project_arguments(['-fdata-sections', '-ffunction-sections'], language : 'cpp')
41af6298daSManojkiran Eda  add_project_arguments('-DNDEBUG', language : 'cpp')
42af6298daSManojkiran Edaendif
43af6298daSManojkiran Eda
44af6298daSManojkiran Eda# Disable lto when compiling with no optimization
45af6298daSManojkiran Edaif(get_option('optimization') == '0')
46af6298daSManojkiran Eda  add_project_arguments('-fno-lto', language: 'cpp')
47af6298daSManojkiran Eda  message('Disabling lto & its supported features as optimization is disabled')
48af6298daSManojkiran Edaendif
49af6298daSManojkiran Eda
50af6298daSManojkiran Eda# Include Directories
51af6298daSManojkiran Eda
52cf2f932eSEd Tanousincdir = include_directories(
53cf2f932eSEd Tanous  'include',
54cf2f932eSEd Tanous  'redfish-core/include',
55cf2f932eSEd Tanous  'redfish-core/lib',
56cf2f932eSEd Tanous  'http'
57cf2f932eSEd Tanous)
58af6298daSManojkiran Eda
59af6298daSManojkiran Eda# Get the options and enable the respective features
60af6298daSManojkiran Eda## create a MAP of  "options : feature_flag"
61af6298daSManojkiran Eda
62af6298daSManojkiran Edafeature_map = {
632d74fbc4SManojkiran Eda  'basic-auth'                                  : '-DBMCWEB_ENABLE_BASIC_AUTHENTICATION',
642d74fbc4SManojkiran Eda  'cookie-auth'                                 : '-DBMCWEB_ENABLE_COOKIE_AUTHENTICATION',
652d74fbc4SManojkiran Eda  'google-api'                                  : '-DBMCWEB_ENABLE_GOOGLE_API',
662d74fbc4SManojkiran Eda  'host-serial-socket'                          : '-DBMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET',
672d74fbc4SManojkiran Eda  'ibm-management-console'                      : '-DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE',
68a43ea82fSNan Zhou  'insecure-disable-auth'                       : '-DBMCWEB_INSECURE_DISABLE_AUTHX',
69af6298daSManojkiran Eda  'insecure-disable-csrf'                       : '-DBMCWEB_INSECURE_DISABLE_CSRF_PREVENTION',
70af6298daSManojkiran Eda  'insecure-disable-ssl'                        : '-DBMCWEB_INSECURE_DISABLE_SSL',
712d74fbc4SManojkiran Eda  'insecure-push-style-notification'            : '-DBMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING',
722d74fbc4SManojkiran Eda  'insecure-tftp-update'                        : '-DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE',
73*1aa0c2b8SEd Tanous  'insecure-ignore-content-type'                : '-DBMCWEB_INSECURE_IGNORE_CONTENT_TYPE',
74af6298daSManojkiran Eda  'kvm'                                         : '-DBMCWEB_ENABLE_KVM' ,
75af6298daSManojkiran Eda  'mutual-tls-auth'                             : '-DBMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION',
767fb33566SCarson Labrado  'redfish-aggregation'                         : '-DBMCWEB_ENABLE_REDFISH_AGGREGATION',
77f523c324SEd Tanous  'redfish-allow-deprecated-power-thermal'      : '-DBMCWEB_ALLOW_DEPRECATED_POWER_THERMAL',
78af6298daSManojkiran Eda  'redfish-bmc-journal'                         : '-DBMCWEB_ENABLE_REDFISH_BMC_JOURNAL',
79af6298daSManojkiran Eda  'redfish-cpu-log'                             : '-DBMCWEB_ENABLE_REDFISH_CPU_LOG',
80af6298daSManojkiran Eda  'redfish-dbus-log'                            : '-DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES',
813fad0d59SRavi Teja  'redfish-dump-log'                            : '-DBMCWEB_ENABLE_REDFISH_DUMP_LOG',
82f523c324SEd Tanous  'redfish-host-logger'                         : '-DBMCWEB_ENABLE_REDFISH_HOST_LOGGER',
832d74fbc4SManojkiran Eda  'redfish-new-powersubsystem-thermalsubsystem' : '-DBMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM',
8454dce7f5SGunnar Mills  'redfish-oem-manager-fan-data'                : '-DBMCWEB_ENABLE_REDFISH_OEM_MANAGER_FAN_DATA',
85f523c324SEd Tanous  'redfish-provisioning-feature'                : '-DBMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE',
864dc23f3fSEd Tanous  'redfish-post-to-old-updateservice'           : '-DBMCWEB_ENABLE_REDFISH_UPDATESERVICE_OLD_POST_URL',
87f523c324SEd Tanous  'redfish'                                     : '-DBMCWEB_ENABLE_REDFISH',
88f523c324SEd Tanous  'rest'                                        : '-DBMCWEB_ENABLE_DBUS_REST',
892d74fbc4SManojkiran Eda  'session-auth'                                : '-DBMCWEB_ENABLE_SESSION_AUTHENTICATION',
90af6298daSManojkiran Eda  'static-hosting'                              : '-DBMCWEB_ENABLE_STATIC_HOSTING',
91af6298daSManojkiran Eda  'vm-websocket'                                : '-DBMCWEB_ENABLE_VM_WEBSOCKET',
922d74fbc4SManojkiran Eda  'xtoken-auth'                                 : '-DBMCWEB_ENABLE_XTOKEN_AUTHENTICATION',
93f523c324SEd Tanous  #'vm-nbdproxy'                                : '-DBMCWEB_ENABLE_VM_NBDPROXY',
94af6298daSManojkiran Eda}
95af6298daSManojkiran Eda
96af6298daSManojkiran Eda# Get the options status and build a project summary to show which flags are
97af6298daSManojkiran Eda# being enabled during the configuration time.
98af6298daSManojkiran Eda
99af6298daSManojkiran Edaforeach option_key,option_value : feature_map
100af6298daSManojkiran Eda  if(get_option(option_key).enabled())
101af6298daSManojkiran Eda    if(option_key == 'mutual-tls-auth' or option_key == 'insecure-disable-ssl')
102af6298daSManojkiran Eda      if(get_option('insecure-disable-ssl').disabled() or get_option('mutual-tls-auth').disabled())
103af6298daSManojkiran Eda        add_project_arguments(option_value,language:'cpp')
104af6298daSManojkiran Eda        summary(option_key,option_value, section : 'Enabled Features')
105af6298daSManojkiran Eda      endif
1063acced2cSNan Zhou    elif (option_key in ['basic-auth', 'cookie-auth', 'session-auth', 'xtoken-auth', 'mutual-tls-auth'])
1073acced2cSNan Zhou      if (get_option('insecure-disable-auth').disabled())
1083acced2cSNan Zhou        add_project_arguments(option_value, language:'cpp')
1093acced2cSNan Zhou        summary(option_key,option_value, section : 'Enabled Features')
1103acced2cSNan Zhou      endif
111af6298daSManojkiran Eda    else
112af6298daSManojkiran Eda      summary(option_key,option_value, section : 'Enabled Features')
113af6298daSManojkiran Eda      add_project_arguments(option_value,language:'cpp')
114af6298daSManojkiran Eda    endif
115af6298daSManojkiran Eda  else
116af6298daSManojkiran Eda      if(option_key == 'insecure-disable-ssl')
117af6298daSManojkiran Eda        summary('ssl','-DBMCWEB_ENABLE_SSL', section : 'Enabled Features')
118af6298daSManojkiran Eda        add_project_arguments('-DBMCWEB_ENABLE_SSL', language : 'cpp')
119af6298daSManojkiran Eda      endif
120af6298daSManojkiran Eda  endif
121af6298daSManojkiran Edaendforeach
122af6298daSManojkiran Eda
123af6298daSManojkiran Edaif(get_option('tests').enabled())
124af6298daSManojkiran Eda  summary('unittest','NA', section : 'Enabled Features')
125af6298daSManojkiran Edaendif
126af6298daSManojkiran Eda
127af6298daSManojkiran Eda# Add compiler arguments
128af6298daSManojkiran Eda
129af6298daSManojkiran Eda# -Wpedantic, -Wextra comes by default with warning level
130af6298daSManojkiran Edaadd_project_arguments(
131af6298daSManojkiran Eda  cxx.get_supported_arguments([
132af6298daSManojkiran Eda  '-Wcast-align',
133af6298daSManojkiran Eda  '-Wconversion',
134f523c324SEd Tanous  '-Wformat=2',
135f523c324SEd Tanous  '-Wold-style-cast',
136f523c324SEd Tanous  '-Woverloaded-virtual',
137af6298daSManojkiran Eda  '-Wsign-conversion',
138f523c324SEd Tanous  '-Wunused',
139af6298daSManojkiran Eda  '-Wno-attributes',
140af6298daSManojkiran Eda  ]),
141af6298daSManojkiran Eda  language: 'cpp'
142af6298daSManojkiran Eda)
143af6298daSManojkiran Eda
144af6298daSManojkiran Edaif (cxx.get_id() == 'clang' and cxx.version().version_compare('>9.0'))
145af6298daSManojkiran Edaadd_project_arguments(
146af6298daSManojkiran Eda  cxx.get_supported_arguments([
147af6298daSManojkiran Eda    '-Weverything',
148af6298daSManojkiran Eda    '-Wno-c++98-compat-pedantic',
149f523c324SEd Tanous    '-Wno-c++98-compat',
150f523c324SEd Tanous    '-Wno-documentation-unknown-command',
151f523c324SEd Tanous    '-Wno-documentation',
152af6298daSManojkiran Eda    '-Wno-exit-time-destructors',
153f523c324SEd Tanous    '-Wno-global-constructors',
154f523c324SEd Tanous    '-Wno-newline-eof',
155f523c324SEd Tanous    '-Wno-padded',
156af6298daSManojkiran Eda    '-Wno-shadow',
157af6298daSManojkiran Eda    '-Wno-used-but-marked-unused',
158af6298daSManojkiran Eda    '-Wno-weak-vtables',
159e6801eb4SEd Tanous    '-Wno-switch-enum',
160af6298daSManojkiran Eda  ]),
161af6298daSManojkiran Eda  language:'cpp')
162af6298daSManojkiran Edaendif
163af6298daSManojkiran Eda
164af6298daSManojkiran Eda# if compiler is gnu-gcc , and version is > 8.0 then we add few more
165af6298daSManojkiran Eda# compiler arguments , we know that will pass
166af6298daSManojkiran Eda
167af6298daSManojkiran Edaif (cxx.get_id() == 'gcc' and cxx.version().version_compare('>8.0'))
168af6298daSManojkiran Eda  add_project_arguments(
169af6298daSManojkiran Eda    cxx.get_supported_arguments([
170af6298daSManojkiran Eda     '-Wduplicated-cond',
171af6298daSManojkiran Eda     '-Wduplicated-branches',
172af6298daSManojkiran Eda     '-Wlogical-op',
173af6298daSManojkiran Eda     '-Wnull-dereference',
174079360aeSEd Tanous     '-Wunused-parameter',
175af6298daSManojkiran Eda     '-Wdouble-promotion',
1768a592810SEd Tanous     '-Wshadow',
17730f11eb4SEd Tanous     '-Wno-psabi',
178af6298daSManojkiran Eda     ]),
179af6298daSManojkiran Eda    language:'cpp')
180c66403c3SEd Tanousendif
181af6298daSManojkiran Eda
182af6298daSManojkiran Edaif (get_option('buildtype') != 'plain')
183af6298daSManojkiran Eda  if (get_option('b_lto') == true and get_option('optimization')!='0')
184af6298daSManojkiran Eda    # Reduce the binary size by removing unnecessary
185af6298daSManojkiran Eda    # dynamic symbol table entries
186af6298daSManojkiran Eda
187af6298daSManojkiran Eda    add_project_arguments(
188af6298daSManojkiran Eda     cxx.get_supported_arguments([
189af6298daSManojkiran Eda     '-fno-fat-lto-objects',
190af6298daSManojkiran Eda     '-fvisibility=hidden',
191af6298daSManojkiran Eda     '-fvisibility-inlines-hidden'
192af6298daSManojkiran Eda     ]),
193af6298daSManojkiran Eda     language: 'cpp')
194af6298daSManojkiran Eda
195af6298daSManojkiran Eda    if cxx.has_link_argument('-Wl,--exclude-libs,ALL')
196af6298daSManojkiran Eda      add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp')
197af6298daSManojkiran Eda    endif
198af6298daSManojkiran Eda  endif
199c66403c3SEd Tanousendif
200af6298daSManojkiran Eda
201620a6e14SManojkiran Edaif( get_option('bmcweb-logging').enabled() or \
202af6298daSManojkiran Eda    get_option('buildtype').startswith('debug'))
203af6298daSManojkiran Eda add_project_arguments([
204af6298daSManojkiran Eda   '-DBMCWEB_ENABLE_LOGGING',
205af6298daSManojkiran Eda   '-DBMCWEB_ENABLE_DEBUG'
206af6298daSManojkiran Eda   ],
207af6298daSManojkiran Eda  language : 'cpp')
208af6298daSManojkiran Eda
209af6298daSManojkiran Eda  summary({'debug' :'-DBMCWEB_ENABLE_DEBUG',
210af6298daSManojkiran Eda     'logging' : '-DBMCWEB_ENABLE_LOGGING',
211af6298daSManojkiran Eda
212e8204933SGeorge Liu    },section : 'Enabled Features')
213e8204933SGeorge Liuendif
214af6298daSManojkiran Eda
215af6298daSManojkiran Eda# Set Compiler Security flags
216af6298daSManojkiran Eda
217af6298daSManojkiran Edasecurity_flags = [
218af6298daSManojkiran Eda  '-fstack-protector-strong',
219af6298daSManojkiran Eda  '-fPIE',
220af6298daSManojkiran Eda  '-fPIC',
221af6298daSManojkiran Eda  '-D_FORTIFY_SOURCE=2',
222af6298daSManojkiran Eda  '-Wformat',
223af6298daSManojkiran Eda  '-Wformat-security'
224af6298daSManojkiran Eda]
225af6298daSManojkiran Eda
226af6298daSManojkiran Eda## Add security flags for builds of type 'release','debugoptimized' and 'minsize'
227af6298daSManojkiran Eda
228af6298daSManojkiran Edaif not (get_option('buildtype') == 'plain' or get_option('buildtype').startswith('debug'))
229af6298daSManojkiran Eda  add_project_arguments(
230af6298daSManojkiran Eda   cxx.get_supported_arguments([
231af6298daSManojkiran Eda    security_flags
232af6298daSManojkiran Eda  ]),
233af6298daSManojkiran Eda  language: 'cpp')
234af6298daSManojkiran Edaendif
235af6298daSManojkiran Eda
236af6298daSManojkiran Eda# Boost dependency configuration
237af6298daSManojkiran Eda
238af6298daSManojkiran Edaadd_project_arguments(
239af6298daSManojkiran Edacxx.get_supported_arguments([
240af6298daSManojkiran Eda  '-DBOOST_ALL_NO_LIB',
24158e42b18SEd Tanous  '-DBOOST_ALLOW_DEPRECATED_HEADERS',
242f523c324SEd Tanous  '-DBOOST_ASIO_DISABLE_THREADS',
243f523c324SEd Tanous  '-DBOOST_ASIO_NO_DEPRECATED',
244f523c324SEd Tanous  '-DBOOST_ASIO_SEPARATE_COMPILATION',
245f523c324SEd Tanous  '-DBOOST_BEAST_SEPARATE_COMPILATION',
2469e710e7fSEd Tanous  '-DBOOST_EXCEPTION_DISABLE',
247ab6b6fecSEd Tanous  '-DBOOST_URL_NO_SOURCE_LOCATION',
2489e710e7fSEd Tanous  '-DJSON_NOEXCEPTION',
249209aa909SEd Tanous  '-DOPENSSL_NO_FILENAMES',
250af6298daSManojkiran Eda]),
251af6298daSManojkiran Edalanguage : 'cpp')
252af6298daSManojkiran Eda
253af6298daSManojkiran Eda# Find the dependency modules, if not found use meson wrap to get them
254af6298daSManojkiran Eda# automatically during the configure step
255ceb8ddc1SJason M. Billsbmcweb_dependencies = []
256af6298daSManojkiran Eda
2578682c5adSNan Zhoupam = cxx.find_library('pam', required: true)
258af6298daSManojkiran Edaatomic =  cxx.find_library('atomic', required: true)
259af6298daSManojkiran Edaopenssl = dependency('openssl', required : true)
260ceb8ddc1SJason M. Billsbmcweb_dependencies += [pam, atomic, openssl]
261af6298daSManojkiran Eda
2627bb985eeSEd Tanoussdbusplus = dependency('sdbusplus', required : false, include_type: 'system')
263af6298daSManojkiran Edaif not sdbusplus.found()
264af6298daSManojkiran Eda  sdbusplus_proj = subproject('sdbusplus', required: true)
265af6298daSManojkiran Eda  sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
266af6298daSManojkiran Eda  sdbusplus = sdbusplus.as_system('system')
267af6298daSManojkiran Edaendif
268ceb8ddc1SJason M. Billsbmcweb_dependencies += sdbusplus
269af6298daSManojkiran Eda
270565c0911SPatrick Williamstinyxml = dependency('tinyxml2',
271565c0911SPatrick Williams    default_options: ['tests=false'],
272565c0911SPatrick Williams    include_type: 'system',
273565c0911SPatrick Williams)
274ceb8ddc1SJason M. Billsbmcweb_dependencies += tinyxml
275af6298daSManojkiran Eda
276af6298daSManojkiran Edasystemd = dependency('systemd')
277af6298daSManojkiran Edazlib = dependency('zlib')
278ceb8ddc1SJason M. Billsbmcweb_dependencies += [systemd, zlib]
279af6298daSManojkiran Eda
280af6298daSManojkiran Edaif cxx.has_header('nlohmann/json.hpp')
281af6298daSManojkiran Eda    nlohmann_json = declare_dependency()
282af6298daSManojkiran Edaelse
283259df359SJosh Lehan    nlohmann_json_proj = subproject('nlohmann', required: true)
284259df359SJosh Lehan    nlohmann_json = nlohmann_json_proj.get_variable('nlohmann_json_dep')
285b00dcc27SEd Tanous    nlohmann_json = nlohmann_json.as_system('system')
286af6298daSManojkiran Edaendif
287ceb8ddc1SJason M. Billsbmcweb_dependencies += nlohmann_json
288af6298daSManojkiran Eda
289079360aeSEd Tanousboost = dependency('boost',version : '>=1.81.0', required : false, include_type: 'system')
290af6298daSManojkiran Edaif not boost.found()
291f165deefSEd Tanous  boost = subproject('boost', required: true).get_variable('boost_dep')
2926c7d53a5SEd Tanous  boost = boost.as_system('system')
293af6298daSManojkiran Edaendif
294ceb8ddc1SJason M. Billsbmcweb_dependencies += boost
295af6298daSManojkiran Eda
296af6298daSManojkiran Edaif get_option('tests').enabled()
297af6298daSManojkiran Eda  gtest = dependency('gtest', main: true,disabler: true, required : false)
298af6298daSManojkiran Eda  gmock = dependency('gmock', required : false)
299af6298daSManojkiran Eda  if not gtest.found() and get_option('tests').enabled()
300af6298daSManojkiran Eda    gtest_proj = subproject('gtest', required: true)
301af6298daSManojkiran Eda    gtest = gtest_proj.get_variable('gtest_main_dep')
302af6298daSManojkiran Eda    gmock = gtest_proj.get_variable('gmock_dep')
303af6298daSManojkiran Eda  endif
304b00dcc27SEd Tanous  gtest = gtest.as_system('system')
305b00dcc27SEd Tanous  gmock = gmock.as_system('system')
306af6298daSManojkiran Edaendif
307af6298daSManojkiran Eda
3086a779931SPatrick Williamssystemd_system_unit_dir = systemd.get_variable(pkgconfig: 'systemdsystemunitdir')
309af6298daSManojkiran Eda
310af6298daSManojkiran Edabindir = get_option('prefix') + '/' +get_option('bindir')
311af6298daSManojkiran Eda
312af6298daSManojkiran Edasummary({
313af6298daSManojkiran Eda          'prefix' : get_option('prefix'),
314af6298daSManojkiran Eda          'bindir' : bindir,
315af6298daSManojkiran Eda          'systemd unit directory' : systemd_system_unit_dir
316af6298daSManojkiran Eda        }, section : 'Directories')
317af6298daSManojkiran Eda
318af6298daSManojkiran Edainstall_subdir('static', install_dir : 'share/www', strip_directory : true)
319af6298daSManojkiran Eda
320307386e8SNan Zhou# Config subdirectory
321307386e8SNan Zhou
322307386e8SNan Zhousubdir('config')
323307386e8SNan Zhoubmcweb_dependencies += conf_h_dep
324307386e8SNan Zhou
32502f1cd9bSEd Tanous# Source files
3260ad63df8SNan Zhoufs = import('fs')
327af6298daSManojkiran Eda
3280ad63df8SNan Zhousrcfiles_bmcweb = files(
32902f1cd9bSEd Tanous  'redfish-core/src/error_messages.cpp',
33002f1cd9bSEd Tanous  'redfish-core/src/utils/json_utils.cpp',
33102f1cd9bSEd Tanous  'src/boost_asio_ssl.cpp',
332f523c324SEd Tanous  'src/boost_asio.cpp',
333f523c324SEd Tanous  'src/boost_beast.cpp',
334f523c324SEd Tanous  'src/boost_url.cpp',
3356384e323SNan Zhou  'src/dbus_singleton.cpp',
3360ad63df8SNan Zhou)
33702f1cd9bSEd Tanous
33842bbcd87SEd Tanousbmcweblib = static_library(
33942bbcd87SEd Tanous  'bmcweblib',
34042bbcd87SEd Tanous  srcfiles_bmcweb,
34142bbcd87SEd Tanous  include_directories : incdir,
34242bbcd87SEd Tanous  dependencies: bmcweb_dependencies,
34342bbcd87SEd Tanous)
34442bbcd87SEd Tanous
34502f1cd9bSEd Tanous# Generate the bmcweb executable
34602f1cd9bSEd Tanousexecutable(
34702f1cd9bSEd Tanous  'bmcweb',
34842bbcd87SEd Tanous  'src/webserver_main.cpp',
349af6298daSManojkiran Eda  include_directories : incdir,
350ceb8ddc1SJason M. Bills  dependencies: bmcweb_dependencies,
35142bbcd87SEd Tanous  link_with: bmcweblib,
3525e34b67aSEd Tanous  link_args: '-Wl,--gc-sections',
353af6298daSManojkiran Eda  install: true,
35402f1cd9bSEd Tanous  install_dir:bindir
35502f1cd9bSEd Tanous)
35602f1cd9bSEd Tanous
3570ad63df8SNan Zhousrcfiles_unittest = files(
358c33a039bSNan Zhou  'test/http/crow_getroutes_test.cpp',
359c33a039bSNan Zhou  'test/http/router_test.cpp',
360c33a039bSNan Zhou  'test/http/utility_test.cpp',
3612c9efc3cSEd Tanous  'test/http/verb_test.cpp',
362c33a039bSNan Zhou  'test/include/dbus_utility_test.cpp',
363c33a039bSNan Zhou  'test/include/google/google_service_root_test.cpp',
364c33a039bSNan Zhou  'test/include/http_utility_test.cpp',
365c33a039bSNan Zhou  'test/include/human_sort_test.cpp',
366c33a039bSNan Zhou  'test/include/ibm/configfile_test.cpp',
367c33a039bSNan Zhou  'test/include/ibm/lock_test.cpp',
368c33a039bSNan Zhou  'test/include/multipart_test.cpp',
369c33a039bSNan Zhou  'test/include/openbmc_dbus_rest_test.cpp',
37050ebd4afSEd Tanous  'test/include/str_utility_test.cpp',
371c33a039bSNan Zhou  'test/redfish-core/include/privileges_test.cpp',
3727e8890c5SCarson Labrado  'test/redfish-core/include/redfish_aggregator_test.cpp',
373c33a039bSNan Zhou  'test/redfish-core/include/registries_test.cpp',
374c33a039bSNan Zhou  'test/redfish-core/include/utils/hex_utils_test.cpp',
375c33a039bSNan Zhou  'test/redfish-core/include/utils/ip_utils_test.cpp',
376c33a039bSNan Zhou  'test/redfish-core/include/utils/json_utils_test.cpp',
377c33a039bSNan Zhou  'test/redfish-core/include/utils/query_param_test.cpp',
378c33a039bSNan Zhou  'test/redfish-core/include/utils/stl_utils_test.cpp',
379c33a039bSNan Zhou  'test/redfish-core/include/utils/time_utils_test.cpp',
380c33a039bSNan Zhou  'test/redfish-core/lib/chassis_test.cpp',
381c71d6125SEd Tanous  'test/redfish-core/lib/sensors_test.cpp',
382c33a039bSNan Zhou  'test/redfish-core/lib/log_services_dump_test.cpp',
383c33a039bSNan Zhou  'test/redfish-core/lib/service_root_test.cpp',
384c33a039bSNan Zhou  'test/redfish-core/lib/thermal_subsystem_test.cpp',
38577b36437SChicago Duan  'test/redfish-core/lib/power_subsystem_test.cpp',
3860ad63df8SNan Zhou)
387af6298daSManojkiran Eda
388af6298daSManojkiran Edaif(get_option('tests').enabled())
38902f1cd9bSEd Tanous    # generate the test executable
3900ad63df8SNan Zhou    foreach test_src : srcfiles_unittest
3910ad63df8SNan Zhou      test_bin = executable(
3920ad63df8SNan Zhou        fs.stem(test_src),
39342bbcd87SEd Tanous        test_src,
39442bbcd87SEd Tanous        link_with: bmcweblib,
395af6298daSManojkiran Eda        include_directories : incdir,
396af6298daSManojkiran Eda        install_dir: bindir,
39702f1cd9bSEd Tanous        dependencies: bmcweb_dependencies + [
398cf2f932eSEd Tanous          gtest,
399cf2f932eSEd Tanous          gmock,
40002f1cd9bSEd Tanous        ]
40102f1cd9bSEd Tanous      )
4020ad63df8SNan Zhou      test(fs.stem(test_src), test_bin)
4030ad63df8SNan Zhou    endforeach
404af6298daSManojkiran Edaendif
405