xref: /openbmc/bmcweb/meson.build (revision 3cd7072b9fff77731b959b2f7b3e3750e50abfe4)
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
44f8ca6d79SEd Tanousif(get_option('dns-resolver') == 'systemd-dbus')
45f8ca6d79SEd Tanous  add_project_arguments('-DBMCWEB_DBUS_DNS_RESOLVER', language : 'cpp')
46f8ca6d79SEd Tanousendif
47f8ca6d79SEd Tanous
48af6298daSManojkiran Eda# Disable lto when compiling with no optimization
49af6298daSManojkiran Edaif(get_option('optimization') == '0')
50af6298daSManojkiran Eda  add_project_arguments('-fno-lto', language: 'cpp')
51af6298daSManojkiran Eda  message('Disabling lto & its supported features as optimization is disabled')
52af6298daSManojkiran Edaendif
53af6298daSManojkiran Eda
54af6298daSManojkiran Eda# Include Directories
55af6298daSManojkiran Eda
56cf2f932eSEd Tanousincdir = include_directories(
57cf2f932eSEd Tanous  'include',
58cf2f932eSEd Tanous  'redfish-core/include',
59cf2f932eSEd Tanous  'redfish-core/lib',
60cf2f932eSEd Tanous  'http'
61cf2f932eSEd Tanous)
62af6298daSManojkiran Eda
63af6298daSManojkiran Eda# Get the options and enable the respective features
64af6298daSManojkiran Eda## create a MAP of  "options : feature_flag"
65af6298daSManojkiran Eda
66af6298daSManojkiran Edafeature_map = {
672d74fbc4SManojkiran Eda  'basic-auth'                                  : '-DBMCWEB_ENABLE_BASIC_AUTHENTICATION',
682d74fbc4SManojkiran Eda  'cookie-auth'                                 : '-DBMCWEB_ENABLE_COOKIE_AUTHENTICATION',
692d74fbc4SManojkiran Eda  'google-api'                                  : '-DBMCWEB_ENABLE_GOOGLE_API',
702d74fbc4SManojkiran Eda  'host-serial-socket'                          : '-DBMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET',
712d74fbc4SManojkiran Eda  'ibm-management-console'                      : '-DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE',
72a43ea82fSNan Zhou  'insecure-disable-auth'                       : '-DBMCWEB_INSECURE_DISABLE_AUTHX',
73af6298daSManojkiran Eda  'insecure-disable-csrf'                       : '-DBMCWEB_INSECURE_DISABLE_CSRF_PREVENTION',
74af6298daSManojkiran Eda  'insecure-disable-ssl'                        : '-DBMCWEB_INSECURE_DISABLE_SSL',
752d74fbc4SManojkiran Eda  'insecure-push-style-notification'            : '-DBMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING',
762d74fbc4SManojkiran Eda  'insecure-tftp-update'                        : '-DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE',
771aa0c2b8SEd Tanous  'insecure-ignore-content-type'                : '-DBMCWEB_INSECURE_IGNORE_CONTENT_TYPE',
78af6298daSManojkiran Eda  'kvm'                                         : '-DBMCWEB_ENABLE_KVM' ,
79af6298daSManojkiran Eda  'mutual-tls-auth'                             : '-DBMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION',
807fb33566SCarson Labrado  'redfish-aggregation'                         : '-DBMCWEB_ENABLE_REDFISH_AGGREGATION',
81f523c324SEd Tanous  'redfish-allow-deprecated-power-thermal'      : '-DBMCWEB_ALLOW_DEPRECATED_POWER_THERMAL',
82af6298daSManojkiran Eda  'redfish-bmc-journal'                         : '-DBMCWEB_ENABLE_REDFISH_BMC_JOURNAL',
83af6298daSManojkiran Eda  'redfish-cpu-log'                             : '-DBMCWEB_ENABLE_REDFISH_CPU_LOG',
84af6298daSManojkiran Eda  'redfish-dbus-log'                            : '-DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES',
853fad0d59SRavi Teja  'redfish-dump-log'                            : '-DBMCWEB_ENABLE_REDFISH_DUMP_LOG',
86f523c324SEd Tanous  'redfish-host-logger'                         : '-DBMCWEB_ENABLE_REDFISH_HOST_LOGGER',
872d74fbc4SManojkiran Eda  'redfish-new-powersubsystem-thermalsubsystem' : '-DBMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM',
8854dce7f5SGunnar Mills  'redfish-oem-manager-fan-data'                : '-DBMCWEB_ENABLE_REDFISH_OEM_MANAGER_FAN_DATA',
89f523c324SEd Tanous  'redfish-provisioning-feature'                : '-DBMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE',
90f523c324SEd Tanous  'redfish'                                     : '-DBMCWEB_ENABLE_REDFISH',
91f523c324SEd Tanous  'rest'                                        : '-DBMCWEB_ENABLE_DBUS_REST',
922d74fbc4SManojkiran Eda  'session-auth'                                : '-DBMCWEB_ENABLE_SESSION_AUTHENTICATION',
93af6298daSManojkiran Eda  'static-hosting'                              : '-DBMCWEB_ENABLE_STATIC_HOSTING',
947f3e84a1SEd Tanous  'experimental-redfish-multi-computer-system'  : '-DBMCWEB_ENABLE_MULTI_COMPUTERSYSTEM',
95af6298daSManojkiran Eda  'vm-websocket'                                : '-DBMCWEB_ENABLE_VM_WEBSOCKET',
962d74fbc4SManojkiran Eda  'xtoken-auth'                                 : '-DBMCWEB_ENABLE_XTOKEN_AUTHENTICATION',
97f523c324SEd Tanous  #'vm-nbdproxy'                                : '-DBMCWEB_ENABLE_VM_NBDPROXY',
98af6298daSManojkiran Eda}
99af6298daSManojkiran Eda
100af6298daSManojkiran Eda# Get the options status and build a project summary to show which flags are
101af6298daSManojkiran Eda# being enabled during the configuration time.
102af6298daSManojkiran Eda
103af6298daSManojkiran Edaforeach option_key,option_value : feature_map
104549bed29SPatrick Williams  if(get_option(option_key).allowed())
105af6298daSManojkiran Eda    if(option_key == 'mutual-tls-auth' or option_key == 'insecure-disable-ssl')
106af6298daSManojkiran Eda      if(get_option('insecure-disable-ssl').disabled() or get_option('mutual-tls-auth').disabled())
107af6298daSManojkiran Eda        add_project_arguments(option_value,language:'cpp')
108af6298daSManojkiran Eda        summary(option_key,option_value, section : 'Enabled Features')
109af6298daSManojkiran Eda      endif
1103acced2cSNan Zhou    elif (option_key in ['basic-auth', 'cookie-auth', 'session-auth', 'xtoken-auth', 'mutual-tls-auth'])
1113acced2cSNan Zhou      if (get_option('insecure-disable-auth').disabled())
1123acced2cSNan Zhou        add_project_arguments(option_value, language:'cpp')
1133acced2cSNan Zhou        summary(option_key,option_value, section : 'Enabled Features')
1143acced2cSNan Zhou      endif
115af6298daSManojkiran Eda    else
116af6298daSManojkiran Eda      summary(option_key,option_value, section : 'Enabled Features')
117af6298daSManojkiran Eda      add_project_arguments(option_value,language:'cpp')
118af6298daSManojkiran Eda    endif
119af6298daSManojkiran Eda  else
120af6298daSManojkiran Eda      if(option_key == 'insecure-disable-ssl')
121af6298daSManojkiran Eda        summary('ssl','-DBMCWEB_ENABLE_SSL', section : 'Enabled Features')
122af6298daSManojkiran Eda        add_project_arguments('-DBMCWEB_ENABLE_SSL', language : 'cpp')
123af6298daSManojkiran Eda      endif
124af6298daSManojkiran Eda  endif
125af6298daSManojkiran Edaendforeach
126af6298daSManojkiran Eda
127549bed29SPatrick Williamsif(get_option('tests').allowed())
128af6298daSManojkiran Eda  summary('unittest','NA', section : 'Enabled Features')
129af6298daSManojkiran Edaendif
130af6298daSManojkiran Eda
131af6298daSManojkiran Eda# Add compiler arguments
132af6298daSManojkiran Eda
133ade3f093SEd Tanousif (cxx.get_id() == 'clang')
134ade3f093SEd Tanous  if (cxx.version().version_compare('<17.0'))
135ade3f093SEd Tanous    error('This project requires clang-17 or higher')
136ade3f093SEd Tanous  endif
137af6298daSManojkiran Eda  add_project_arguments(
138af6298daSManojkiran Eda    '-Weverything',
139ade3f093SEd Tanous    '-Wformat=2',
140af6298daSManojkiran Eda    '-Wno-c++98-compat-pedantic',
141f523c324SEd Tanous    '-Wno-c++98-compat',
142f523c324SEd Tanous    '-Wno-documentation-unknown-command',
143f523c324SEd Tanous    '-Wno-documentation',
144af6298daSManojkiran Eda    '-Wno-exit-time-destructors',
145f523c324SEd Tanous    '-Wno-global-constructors',
146f523c324SEd Tanous    '-Wno-newline-eof',
147f523c324SEd Tanous    '-Wno-padded',
148af6298daSManojkiran Eda    '-Wno-shadow',
149af6298daSManojkiran Eda    '-Wno-used-but-marked-unused',
150af6298daSManojkiran Eda    '-Wno-weak-vtables',
151e6801eb4SEd Tanous    '-Wno-switch-enum',
15272b90760SEd Tanous    '-Wno-unused-macros',
1534da0490bSEd Tanous    '-Wno-covered-switch-default',
154af6298daSManojkiran Eda    language:'cpp')
155af6298daSManojkiran Edaendif
156af6298daSManojkiran Eda
157ade3f093SEd Tanousif (cxx.get_id() == 'gcc')
158ade3f093SEd Tanous  if (cxx.version().version_compare('<13.0'))
159ade3f093SEd Tanous    error('This project requires gcc-13 or higher')
160ade3f093SEd Tanous  endif
161af6298daSManojkiran Eda
162af6298daSManojkiran Eda  add_project_arguments(
163ade3f093SEd Tanous    '-Wformat=2',
164ade3f093SEd Tanous    '-Wcast-align',
165ade3f093SEd Tanous    '-Wconversion',
166ade3f093SEd Tanous    '-Woverloaded-virtual',
167ade3f093SEd Tanous    '-Wsign-conversion',
168ade3f093SEd Tanous    '-Wunused',
169af6298daSManojkiran Eda    '-Wduplicated-cond',
170af6298daSManojkiran Eda    '-Wduplicated-branches',
171af6298daSManojkiran Eda    '-Wlogical-op',
172af6298daSManojkiran Eda    '-Wnull-dereference',
173079360aeSEd Tanous    '-Wunused-parameter',
174af6298daSManojkiran Eda    '-Wdouble-promotion',
1758a592810SEd Tanous    '-Wshadow',
17630f11eb4SEd Tanous    '-Wno-psabi',
177ade3f093SEd Tanous    '-Wno-attributes',
178af6298daSManojkiran Eda    language:'cpp')
179c66403c3SEd Tanousendif
180af6298daSManojkiran Eda
181af6298daSManojkiran Edaif (get_option('buildtype') != 'plain')
182af6298daSManojkiran Eda  if (get_option('b_lto') == true and get_option('optimization')!='0')
183af6298daSManojkiran Eda    # Reduce the binary size by removing unnecessary
184af6298daSManojkiran Eda    # dynamic symbol table entries
185af6298daSManojkiran Eda
186af6298daSManojkiran Eda    add_project_arguments(
187af6298daSManojkiran Eda     cxx.get_supported_arguments([
188af6298daSManojkiran Eda     '-fno-fat-lto-objects',
189af6298daSManojkiran Eda     '-fvisibility=hidden',
190af6298daSManojkiran Eda     '-fvisibility-inlines-hidden'
191af6298daSManojkiran Eda     ]),
192af6298daSManojkiran Eda     language: 'cpp')
193af6298daSManojkiran Eda
194af6298daSManojkiran Eda    if cxx.has_link_argument('-Wl,--exclude-libs,ALL')
195af6298daSManojkiran Eda      add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp')
196af6298daSManojkiran Eda    endif
197af6298daSManojkiran Eda  endif
198c66403c3SEd Tanousendif
199af6298daSManojkiran Eda
200662aa6e3SMyung Baeif( get_option('bmcweb-logging') != 'disabled' or \
201af6298daSManojkiran Eda    get_option('buildtype').startswith('debug'))
202af6298daSManojkiran Eda add_project_arguments([
203af6298daSManojkiran Eda   '-DBMCWEB_ENABLE_DEBUG'
204af6298daSManojkiran Eda   ],
205af6298daSManojkiran Eda  language : 'cpp')
206af6298daSManojkiran Eda
207662aa6e3SMyung Bae  summary('debug', '-DBMCWEB_ENABLE_DEBUG', section : 'Enabled Features')
208e8204933SGeorge Liuendif
209af6298daSManojkiran Eda
210af6298daSManojkiran Eda# Set Compiler Security flags
211af6298daSManojkiran Eda
212af6298daSManojkiran Edasecurity_flags = [
213af6298daSManojkiran Eda  '-fstack-protector-strong',
214af6298daSManojkiran Eda  '-fPIE',
215af6298daSManojkiran Eda  '-fPIC',
216af6298daSManojkiran Eda  '-D_FORTIFY_SOURCE=2',
217af6298daSManojkiran Eda  '-Wformat',
218af6298daSManojkiran Eda  '-Wformat-security'
219af6298daSManojkiran Eda]
220af6298daSManojkiran Eda
221af6298daSManojkiran Eda## Add security flags for builds of type 'release','debugoptimized' and 'minsize'
222af6298daSManojkiran Eda
223af6298daSManojkiran Edaif not (get_option('buildtype') == 'plain' or get_option('buildtype').startswith('debug'))
224af6298daSManojkiran Eda  add_project_arguments(
225af6298daSManojkiran Eda   cxx.get_supported_arguments([
226af6298daSManojkiran Eda    security_flags
227af6298daSManojkiran Eda  ]),
228af6298daSManojkiran Eda  language: 'cpp')
229af6298daSManojkiran Edaendif
230af6298daSManojkiran Eda
231af6298daSManojkiran Eda# Boost dependency configuration
232af6298daSManojkiran Eda
233af6298daSManojkiran Edaadd_project_arguments(
234af6298daSManojkiran Edacxx.get_supported_arguments([
2356fd29553SEd Tanous  '-DBOOST_ASIO_DISABLE_CONCEPTS',
236af6298daSManojkiran Eda  '-DBOOST_ALL_NO_LIB',
23758e42b18SEd Tanous  '-DBOOST_ALLOW_DEPRECATED_HEADERS',
238f523c324SEd Tanous  '-DBOOST_ASIO_DISABLE_THREADS',
239f523c324SEd Tanous  '-DBOOST_ASIO_NO_DEPRECATED',
240f523c324SEd Tanous  '-DBOOST_ASIO_SEPARATE_COMPILATION',
241f523c324SEd Tanous  '-DBOOST_BEAST_SEPARATE_COMPILATION',
2429e710e7fSEd Tanous  '-DBOOST_EXCEPTION_DISABLE',
243f706551dSEd Tanous  '-DBOOST_NO_EXCEPTIONS',
244ab6b6fecSEd Tanous  '-DBOOST_URL_NO_SOURCE_LOCATION',
2459e710e7fSEd Tanous  '-DJSON_NOEXCEPTION',
246209aa909SEd Tanous  '-DOPENSSL_NO_FILENAMES',
247f706551dSEd Tanous  '-DSDBUSPLUS_DISABLE_BOOST_COROUTINES',
248af6298daSManojkiran Eda]),
249af6298daSManojkiran Edalanguage : 'cpp')
250af6298daSManojkiran Eda
251af6298daSManojkiran Eda# Find the dependency modules, if not found use meson wrap to get them
252af6298daSManojkiran Eda# automatically during the configure step
253ceb8ddc1SJason M. Billsbmcweb_dependencies = []
254af6298daSManojkiran Eda
2558682c5adSNan Zhoupam = cxx.find_library('pam', required: true)
256af6298daSManojkiran Edaatomic =  cxx.find_library('atomic', required: true)
257e7923997SEd Tanousbmcweb_dependencies += [pam, atomic]
258e7923997SEd Tanous
259e7923997SEd Tanousopenssl = dependency('openssl', required : false, version: '>=3.0.0')
260e7923997SEd Tanousif not openssl.found() or get_option('b_sanitize') != 'none'
261e7923997SEd Tanous  openssl_proj = subproject(
262e7923997SEd Tanous    'openssl',
263e7923997SEd Tanous    required: true,
264e7923997SEd Tanous    default_options: ['warning_level=0', 'werror=false']
265e7923997SEd Tanous  )
266e7923997SEd Tanous  openssl = openssl_proj.get_variable('openssl_dep')
267e7923997SEd Tanous  openssl = openssl.as_system('system')
268e7923997SEd Tanouselse
269e7923997SEd Tanous  # When we build openssl as a subproject, the warnings analyzer starts
270e7923997SEd Tanous  # flagging all the C macros as old style casts, so only enable the
271e7923997SEd Tanous  # warning for non subprojects.
272e7923997SEd Tanous  add_project_arguments('-Wold-style-cast', language: 'cpp')
273e7923997SEd Tanousendif
274e7923997SEd Tanousbmcweb_dependencies += [openssl]
275af6298daSManojkiran Eda
276fca2cbeaSEd Tanousnghttp2 = dependency('libnghttp2', version: '>=1.52.0', required : false)
277fca2cbeaSEd Tanousif not nghttp2.found()
278fca2cbeaSEd Tanous  cmake = import('cmake')
279fca2cbeaSEd Tanous  opt_var = cmake.subproject_options()
280fca2cbeaSEd Tanous  opt_var.add_cmake_defines({
281fca2cbeaSEd Tanous    'ENABLE_LIB_ONLY': true,
282fca2cbeaSEd Tanous    'ENABLE_STATIC_LIB': true
283fca2cbeaSEd Tanous  })
284fca2cbeaSEd Tanous  nghttp2_ex = cmake.subproject('nghttp2', options: opt_var)
285144983c5SEd Tanous  nghttp2 = nghttp2_ex.dependency('nghttp2_static')
286fca2cbeaSEd Tanousendif
287fca2cbeaSEd Tanousbmcweb_dependencies += nghttp2
288fca2cbeaSEd Tanous
2897bb985eeSEd Tanoussdbusplus = dependency('sdbusplus', required : false, include_type: 'system')
290af6298daSManojkiran Edaif not sdbusplus.found()
291af6298daSManojkiran Eda  sdbusplus_proj = subproject('sdbusplus', required: true)
292af6298daSManojkiran Eda  sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
293af6298daSManojkiran Eda  sdbusplus = sdbusplus.as_system('system')
294af6298daSManojkiran Edaendif
295ceb8ddc1SJason M. Billsbmcweb_dependencies += sdbusplus
296af6298daSManojkiran Eda
297c9374ff6SEd Tanoustinyxml = dependency(
298c9374ff6SEd Tanous    'tinyxml2',
299565c0911SPatrick Williams    include_type: 'system',
300c9374ff6SEd Tanous    version: '>=9.0.0',
30160e299bdSKonstantin Aladyshev    default_options: ['tests=false'],
302565c0911SPatrick Williams)
303c9374ff6SEd Tanousif not tinyxml.found()
304c9374ff6SEd Tanous    tinyxml_proj = subproject('tinyxml2', required: true)
305c9374ff6SEd Tanous    tinyxml = tinyxml_proj.get_variable('tinyxml_dep')
306c9374ff6SEd Tanous    tinyxml = tinyxml.as_system('system')
307c9374ff6SEd Tanousendif
308ceb8ddc1SJason M. Billsbmcweb_dependencies += tinyxml
309af6298daSManojkiran Eda
310af6298daSManojkiran Edasystemd = dependency('systemd')
311af6298daSManojkiran Edazlib = dependency('zlib')
312ceb8ddc1SJason M. Billsbmcweb_dependencies += [systemd, zlib]
313af6298daSManojkiran Eda
314dfd5547bSPatrick Williamsnlohmann_json_dep = dependency('nlohmann_json', version: '>=3.11.2', include_type: 'system')
315dfd5547bSPatrick Williamsbmcweb_dependencies += nlohmann_json_dep
316af6298daSManojkiran Eda
3172b5b4daeSCarson Labradoboost = dependency(
3182b5b4daeSCarson Labrado  'boost',
3192b5b4daeSCarson Labrado  modules: [
3202b5b4daeSCarson Labrado    'url',
3212b5b4daeSCarson Labrado    ],
322619b8609SEd Tanous  version : '>=1.84.0',
3232b5b4daeSCarson Labrado  required : false,
3242b5b4daeSCarson Labrado  include_type: 'system'
3252b5b4daeSCarson Labrado)
3266fd29553SEd Tanousif boost.found()
3276fd29553SEd Tanous  bmcweb_dependencies += [boost]
3286fd29553SEd Tanouselse
3296fd29553SEd Tanous  cmake = import('cmake')
3306fd29553SEd Tanous  opt = cmake.subproject_options()
3316fd29553SEd Tanous  opt.add_cmake_defines({
332144983c5SEd Tanous    'BOOST_INCLUDE_LIBRARIES': 'asio;beast;callable_traits;headers;process;type_index;url;uuid',
333144983c5SEd Tanous    'BUILD_SHARED_LIBS': 'OFF',
3346fd29553SEd Tanous  })
335144983c5SEd Tanous
3366fd29553SEd Tanous  boost = cmake.subproject('boost', required: true, options: opt)
3372b5b4daeSCarson Labrado  boost_asio = boost.dependency('boost_asio').as_system()
3382b5b4daeSCarson Labrado  boost_beast = boost.dependency('boost_beast').as_system()
3392b5b4daeSCarson Labrado  boost_callable_traits = boost.dependency('boost_callable_traits').as_system()
3406fd29553SEd Tanous  boost_headers = boost.dependency('boost_headers').as_system()
3412b5b4daeSCarson Labrado  boost_process = boost.dependency('boost_process').as_system()
3422b5b4daeSCarson Labrado  boost_type_index = boost.dependency('boost_type_index').as_system()
3432b5b4daeSCarson Labrado  boost_url = boost.dependency('boost_url').as_system()
3442b5b4daeSCarson Labrado  boost_uuid = boost.dependency('boost_uuid').as_system()
3452b5b4daeSCarson Labrado  bmcweb_dependencies += [
3462b5b4daeSCarson Labrado    boost_asio,
3472b5b4daeSCarson Labrado    boost_beast,
3482b5b4daeSCarson Labrado    boost_callable_traits,
3492b5b4daeSCarson Labrado    boost_headers,
3502b5b4daeSCarson Labrado    boost_process,
3512b5b4daeSCarson Labrado    boost_type_index,
3522b5b4daeSCarson Labrado    boost_url,
3532b5b4daeSCarson Labrado    boost_uuid
3542b5b4daeSCarson Labrado  ]
355af6298daSManojkiran Edaendif
356af6298daSManojkiran Eda
357549bed29SPatrick Williamsif get_option('tests').allowed()
3587a6f0031SEd Tanous  gtest = dependency('gtest', main: true, version: '>=1.14.0', disabler: true, required : false)
359af6298daSManojkiran Eda  gmock = dependency('gmock', required : false)
360549bed29SPatrick Williams  if not gtest.found() and get_option('tests').allowed()
361af6298daSManojkiran Eda    gtest_proj = subproject('gtest', required: true)
362af6298daSManojkiran Eda    gtest = gtest_proj.get_variable('gtest_main_dep')
363af6298daSManojkiran Eda    gmock = gtest_proj.get_variable('gmock_dep')
364af6298daSManojkiran Eda  endif
365b00dcc27SEd Tanous  gtest = gtest.as_system('system')
366b00dcc27SEd Tanous  gmock = gmock.as_system('system')
367af6298daSManojkiran Edaendif
368af6298daSManojkiran Eda
3694efe3e0cSPatrick Williamssystemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir')
370af6298daSManojkiran Eda
371af6298daSManojkiran Edabindir = get_option('prefix') + '/' +get_option('bindir')
372af6298daSManojkiran Eda
373af6298daSManojkiran Edasummary({
374af6298daSManojkiran Eda          'prefix' : get_option('prefix'),
375af6298daSManojkiran Eda          'bindir' : bindir,
376af6298daSManojkiran Eda          'systemd unit directory' : systemd_system_unit_dir
377af6298daSManojkiran Eda        }, section : 'Directories')
378af6298daSManojkiran Eda
379af6298daSManojkiran Edainstall_subdir('static', install_dir : 'share/www', strip_directory : true)
380af6298daSManojkiran Eda
381307386e8SNan Zhou# Config subdirectory
382307386e8SNan Zhou
383307386e8SNan Zhousubdir('config')
384307386e8SNan Zhoubmcweb_dependencies += conf_h_dep
385307386e8SNan Zhou
38602f1cd9bSEd Tanous# Source files
3870ad63df8SNan Zhoufs = import('fs')
388af6298daSManojkiran Eda
3890ad63df8SNan Zhousrcfiles_bmcweb = files(
390*3cd7072bSEd Tanous  # Begin large files, should be at the beginning
391*3cd7072bSEd Tanous  'redfish-core/src/redfish.cpp',
392*3cd7072bSEd Tanous  'src/webserver_run.cpp',
393*3cd7072bSEd Tanous  # end large files
394*3cd7072bSEd Tanous
39502f1cd9bSEd Tanous  'redfish-core/src/error_messages.cpp',
396d1d411f9SSui Chen  'redfish-core/src/registries.cpp',
397d02aad39SEd Tanous  'redfish-core/src/utils/dbus_utils.cpp',
39802f1cd9bSEd Tanous  'redfish-core/src/utils/json_utils.cpp',
399*3cd7072bSEd Tanous  'redfish-core/src/utils/time_utils.cpp',
40002f1cd9bSEd Tanous  'src/boost_asio_ssl.cpp',
401f523c324SEd Tanous  'src/boost_asio.cpp',
402f523c324SEd Tanous  'src/boost_beast.cpp',
4036384e323SNan Zhou  'src/dbus_singleton.cpp',
40461e349acSEd Tanous  'src/json_html_serializer.cpp',
4052c6ffdb0SEd Tanous  'src/ossl_random.cpp',
4060ad63df8SNan Zhou)
40702f1cd9bSEd Tanous
40842bbcd87SEd Tanousbmcweblib = static_library(
40942bbcd87SEd Tanous  'bmcweblib',
41042bbcd87SEd Tanous  srcfiles_bmcweb,
41142bbcd87SEd Tanous  include_directories : incdir,
41242bbcd87SEd Tanous  dependencies: bmcweb_dependencies,
41342bbcd87SEd Tanous)
41442bbcd87SEd Tanous
41502f1cd9bSEd Tanous# Generate the bmcweb executable
41602f1cd9bSEd Tanousexecutable(
41702f1cd9bSEd Tanous  'bmcweb',
41842bbcd87SEd Tanous  'src/webserver_main.cpp',
419af6298daSManojkiran Eda  include_directories : incdir,
420ceb8ddc1SJason M. Bills  dependencies: bmcweb_dependencies,
42142bbcd87SEd Tanous  link_with: bmcweblib,
4225e34b67aSEd Tanous  link_args: '-Wl,--gc-sections',
423af6298daSManojkiran Eda  install: true,
42402f1cd9bSEd Tanous  install_dir:bindir
42502f1cd9bSEd Tanous)
42602f1cd9bSEd Tanous
4270ad63df8SNan Zhousrcfiles_unittest = files(
428c33a039bSNan Zhou  'test/http/crow_getroutes_test.cpp',
42952dd6932SEd Tanous  'test/http/http2_connection_test.cpp',
4304fa45dffSEd Tanous  'test/http/http_connection_test.cpp',
431e7923997SEd Tanous  'test/http/mutual_tls.cpp',
432c33a039bSNan Zhou  'test/http/router_test.cpp',
4331fccd0d5SEd Tanous  'test/http/parsing_test.cpp',
4348e3f7032SAbhilash Raju  'test/http/http_response_test.cpp',
435c33a039bSNan Zhou  'test/http/utility_test.cpp',
4362c9efc3cSEd Tanous  'test/http/verb_test.cpp',
4378f79c5b6SEd Tanous  'test/http/server_sent_event_test.cpp',
4380e373b53SMarco Kawajiri  'test/http/mutual_tls_meta.cpp',
439b2896149SEd Tanous  'test/http/http_body_test.cpp',
440c33a039bSNan Zhou  'test/include/dbus_utility_test.cpp',
441c33a039bSNan Zhou  'test/include/google/google_service_root_test.cpp',
4425a60c56fSEd Tanous  'test/include/json_html_serializer.cpp',
443c33a039bSNan Zhou  'test/include/http_utility_test.cpp',
444c33a039bSNan Zhou  'test/include/human_sort_test.cpp',
445e1452beaSEd Tanous  'test/include/async_resolve_test.cpp',
44611e8f60dSEd Tanous  'test/include/credential_pipe_test.cpp',
447c33a039bSNan Zhou  'test/include/ibm/configfile_test.cpp',
448c33a039bSNan Zhou  'test/include/ibm/lock_test.cpp',
449c33a039bSNan Zhou  'test/include/multipart_test.cpp',
450c33a039bSNan Zhou  'test/include/openbmc_dbus_rest_test.cpp',
45150ebd4afSEd Tanous  'test/include/str_utility_test.cpp',
4522c6ffdb0SEd Tanous  'test/include/ossl_random.cpp',
453c33a039bSNan Zhou  'test/redfish-core/include/privileges_test.cpp',
4547e8890c5SCarson Labrado  'test/redfish-core/include/redfish_aggregator_test.cpp',
455c33a039bSNan Zhou  'test/redfish-core/include/registries_test.cpp',
456c33a039bSNan Zhou  'test/redfish-core/include/utils/hex_utils_test.cpp',
457d02aad39SEd Tanous  'test/redfish-core/include/utils/dbus_utils.cpp',
458c33a039bSNan Zhou  'test/redfish-core/include/utils/ip_utils_test.cpp',
459c33a039bSNan Zhou  'test/redfish-core/include/utils/json_utils_test.cpp',
460c33a039bSNan Zhou  'test/redfish-core/include/utils/query_param_test.cpp',
461c33a039bSNan Zhou  'test/redfish-core/include/utils/stl_utils_test.cpp',
462c33a039bSNan Zhou  'test/redfish-core/include/utils/time_utils_test.cpp',
463c33a039bSNan Zhou  'test/redfish-core/lib/chassis_test.cpp',
464c71d6125SEd Tanous  'test/redfish-core/lib/sensors_test.cpp',
46533e1f122SAndrew Geissler  'test/redfish-core/lib/system_test.cpp',
466c33a039bSNan Zhou  'test/redfish-core/lib/log_services_dump_test.cpp',
46775e8e218SMyung Bae  'test/redfish-core/lib/log_services_test.cpp',
468f86bcc87SEd Tanous  'test/redfish-core/lib/update_service_test.cpp',
469c33a039bSNan Zhou  'test/redfish-core/lib/service_root_test.cpp',
470c33a039bSNan Zhou  'test/redfish-core/lib/thermal_subsystem_test.cpp',
47177b36437SChicago Duan  'test/redfish-core/lib/power_subsystem_test.cpp',
472e610b316SJagpal Singh Gill  'test/redfish-core/lib/manager_diagnostic_data_test.cpp',
4730ad63df8SNan Zhou)
474af6298daSManojkiran Eda
475e7923997SEd Tanous
476549bed29SPatrick Williamsif(get_option('tests').allowed())
47702f1cd9bSEd Tanous    # generate the test executable
4780ad63df8SNan Zhou    foreach test_src : srcfiles_unittest
4790ad63df8SNan Zhou      test_bin = executable(
4800ad63df8SNan Zhou        fs.stem(test_src),
48142bbcd87SEd Tanous        test_src,
48242bbcd87SEd Tanous        link_with: bmcweblib,
483af6298daSManojkiran Eda        include_directories : incdir,
484af6298daSManojkiran Eda        install_dir: bindir,
48502f1cd9bSEd Tanous        dependencies: bmcweb_dependencies + [
486cf2f932eSEd Tanous          gtest,
487cf2f932eSEd Tanous          gmock,
48802f1cd9bSEd Tanous        ]
48902f1cd9bSEd Tanous      )
4900ad63df8SNan Zhou      test(fs.stem(test_src), test_bin)
4910ad63df8SNan Zhou    endforeach
492af6298daSManojkiran Edaendif
493