Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 1 | project('bmcweb', 'cpp', |
| 2 | version : '1.0', |
Ed Tanous | 6107da1 | 2022-10-25 12:05:02 -0700 | [diff] [blame] | 3 | meson_version: '>=0.63.0', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 4 | default_options: [ |
Manojkiran Eda | cb2ed19 | 2021-02-15 08:30:43 +0530 | [diff] [blame] | 5 | 'b_lto_mode=default', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 6 | 'b_lto_threads=0', |
| 7 | 'b_lto=true', |
| 8 | 'b_ndebug=if-release', |
| 9 | 'buildtype=debugoptimized', |
| 10 | 'cpp_rtti=false', |
| 11 | 'cpp_std=c++20', |
| 12 | 'warning_level=3', |
| 13 | 'werror=true', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 14 | ]) |
| 15 | |
| 16 | # Project related links |
| 17 | |
| 18 | project_pretty_name = 'bmcweb' |
| 19 | project_url = 'https://github.com/openbmc/' + project_pretty_name |
| 20 | project_issues_url = project_url + '/issues/new' |
| 21 | summary('Issues',project_issues_url, section: 'Report Issues') |
| 22 | |
| 23 | # Validate the c++ Standard |
| 24 | |
Patrick Williams | c52ee72 | 2021-10-06 15:17:42 -0500 | [diff] [blame] | 25 | if get_option('cpp_std') != 'c++20' |
| 26 | error('This project requires c++20 support') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 27 | endif |
| 28 | |
| 29 | # Get compiler and default build type |
| 30 | |
| 31 | cxx = meson.get_compiler('cpp') |
| 32 | build = get_option('buildtype') |
| 33 | optimization = get_option('optimization') |
| 34 | summary('Build Type',build, section : 'Build Info') |
| 35 | summary('Optimization',optimization, section : 'Build Info') |
| 36 | |
Ed Tanous | 5e34b67 | 2021-02-05 14:21:27 -0800 | [diff] [blame] | 37 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 38 | # remove debug information for minsize buildtype |
| 39 | if(get_option('buildtype') == 'minsize') |
Ed Tanous | 5e34b67 | 2021-02-05 14:21:27 -0800 | [diff] [blame] | 40 | add_project_arguments(['-fdata-sections', '-ffunction-sections'], language : 'cpp') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 41 | add_project_arguments('-DNDEBUG', language : 'cpp') |
| 42 | endif |
| 43 | |
| 44 | # Disable lto when compiling with no optimization |
| 45 | if(get_option('optimization') == '0') |
| 46 | add_project_arguments('-fno-lto', language: 'cpp') |
| 47 | message('Disabling lto & its supported features as optimization is disabled') |
| 48 | endif |
| 49 | |
| 50 | # Include Directories |
| 51 | |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 52 | incdir = include_directories( |
| 53 | 'include', |
| 54 | 'redfish-core/include', |
| 55 | 'redfish-core/lib', |
| 56 | 'http' |
| 57 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 58 | |
| 59 | # Get the options and enable the respective features |
| 60 | ## create a MAP of "options : feature_flag" |
| 61 | |
| 62 | feature_map = { |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 63 | 'basic-auth' : '-DBMCWEB_ENABLE_BASIC_AUTHENTICATION', |
| 64 | 'cookie-auth' : '-DBMCWEB_ENABLE_COOKIE_AUTHENTICATION', |
| 65 | 'google-api' : '-DBMCWEB_ENABLE_GOOGLE_API', |
| 66 | 'host-serial-socket' : '-DBMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET', |
| 67 | 'ibm-management-console' : '-DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE', |
Nan Zhou | a43ea82 | 2022-05-27 00:42:44 +0000 | [diff] [blame] | 68 | 'insecure-disable-auth' : '-DBMCWEB_INSECURE_DISABLE_AUTHX', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 69 | 'insecure-disable-csrf' : '-DBMCWEB_INSECURE_DISABLE_CSRF_PREVENTION', |
| 70 | 'insecure-disable-ssl' : '-DBMCWEB_INSECURE_DISABLE_SSL', |
| 71 | 'insecure-push-style-notification' : '-DBMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING', |
| 72 | 'insecure-tftp-update' : '-DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE', |
| 73 | 'kvm' : '-DBMCWEB_ENABLE_KVM' , |
| 74 | 'mutual-tls-auth' : '-DBMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION', |
Carson Labrado | 7fb3356 | 2022-04-18 23:26:56 +0000 | [diff] [blame] | 75 | 'redfish-aggregation' : '-DBMCWEB_ENABLE_REDFISH_AGGREGATION', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 76 | 'redfish-allow-deprecated-power-thermal' : '-DBMCWEB_ALLOW_DEPRECATED_POWER_THERMAL', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 77 | 'redfish-bmc-journal' : '-DBMCWEB_ENABLE_REDFISH_BMC_JOURNAL', |
| 78 | 'redfish-cpu-log' : '-DBMCWEB_ENABLE_REDFISH_CPU_LOG', |
| 79 | 'redfish-dbus-log' : '-DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES', |
| 80 | 'redfish-dump-log' : '-DBMCWEB_ENABLE_REDFISH_DUMP_LOG', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 81 | 'redfish-host-logger' : '-DBMCWEB_ENABLE_REDFISH_HOST_LOGGER', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 82 | 'redfish-new-powersubsystem-thermalsubsystem' : '-DBMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM', |
Gunnar Mills | 54dce7f | 2022-08-05 17:01:32 +0000 | [diff] [blame] | 83 | 'redfish-oem-manager-fan-data' : '-DBMCWEB_ENABLE_REDFISH_OEM_MANAGER_FAN_DATA', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 84 | 'redfish-provisioning-feature' : '-DBMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE', |
Ed Tanous | 4dc23f3 | 2022-05-11 11:32:19 -0700 | [diff] [blame] | 85 | 'redfish-post-to-old-updateservice' : '-DBMCWEB_ENABLE_REDFISH_UPDATESERVICE_OLD_POST_URL', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 86 | 'redfish' : '-DBMCWEB_ENABLE_REDFISH', |
| 87 | 'rest' : '-DBMCWEB_ENABLE_DBUS_REST', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 88 | 'session-auth' : '-DBMCWEB_ENABLE_SESSION_AUTHENTICATION', |
| 89 | 'static-hosting' : '-DBMCWEB_ENABLE_STATIC_HOSTING', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 90 | 'vm-websocket' : '-DBMCWEB_ENABLE_VM_WEBSOCKET', |
| 91 | 'xtoken-auth' : '-DBMCWEB_ENABLE_XTOKEN_AUTHENTICATION', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 92 | #'vm-nbdproxy' : '-DBMCWEB_ENABLE_VM_NBDPROXY', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | # Get the options status and build a project summary to show which flags are |
| 96 | # being enabled during the configuration time. |
| 97 | |
| 98 | foreach option_key,option_value : feature_map |
| 99 | if(get_option(option_key).enabled()) |
| 100 | if(option_key == 'mutual-tls-auth' or option_key == 'insecure-disable-ssl') |
| 101 | if(get_option('insecure-disable-ssl').disabled() or get_option('mutual-tls-auth').disabled()) |
| 102 | add_project_arguments(option_value,language:'cpp') |
| 103 | summary(option_key,option_value, section : 'Enabled Features') |
| 104 | endif |
Nan Zhou | 3acced2 | 2022-07-12 23:21:02 +0000 | [diff] [blame] | 105 | elif (option_key in ['basic-auth', 'cookie-auth', 'session-auth', 'xtoken-auth', 'mutual-tls-auth']) |
| 106 | if (get_option('insecure-disable-auth').disabled()) |
| 107 | add_project_arguments(option_value, language:'cpp') |
| 108 | summary(option_key,option_value, section : 'Enabled Features') |
| 109 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 110 | else |
| 111 | summary(option_key,option_value, section : 'Enabled Features') |
| 112 | add_project_arguments(option_value,language:'cpp') |
| 113 | endif |
| 114 | else |
| 115 | if(option_key == 'insecure-disable-ssl') |
| 116 | summary('ssl','-DBMCWEB_ENABLE_SSL', section : 'Enabled Features') |
| 117 | add_project_arguments('-DBMCWEB_ENABLE_SSL', language : 'cpp') |
| 118 | endif |
| 119 | endif |
| 120 | endforeach |
| 121 | |
| 122 | if(get_option('tests').enabled()) |
| 123 | summary('unittest','NA', section : 'Enabled Features') |
| 124 | endif |
| 125 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 126 | # Add compiler arguments |
| 127 | |
| 128 | # -Wpedantic, -Wextra comes by default with warning level |
| 129 | add_project_arguments( |
| 130 | cxx.get_supported_arguments([ |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 131 | '-Wcast-align', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 132 | '-Wconversion', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 133 | '-Wformat=2', |
| 134 | '-Wold-style-cast', |
| 135 | '-Woverloaded-virtual', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 136 | '-Wsign-conversion', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 137 | '-Wunused', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 138 | '-Wno-attributes', |
| 139 | ]), |
| 140 | language: 'cpp' |
| 141 | ) |
| 142 | |
| 143 | if (cxx.get_id() == 'clang' and cxx.version().version_compare('>9.0')) |
| 144 | add_project_arguments( |
| 145 | cxx.get_supported_arguments([ |
| 146 | '-Weverything', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 147 | '-Wno-c++98-compat-pedantic', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 148 | '-Wno-c++98-compat', |
| 149 | '-Wno-documentation-unknown-command', |
| 150 | '-Wno-documentation', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 151 | '-Wno-exit-time-destructors', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 152 | '-Wno-global-constructors', |
| 153 | '-Wno-newline-eof', |
| 154 | '-Wno-padded', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 155 | '-Wno-shadow', |
| 156 | '-Wno-used-but-marked-unused', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 157 | '-Wno-weak-vtables', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 158 | ]), |
| 159 | language:'cpp') |
| 160 | endif |
| 161 | |
| 162 | # if compiler is gnu-gcc , and version is > 8.0 then we add few more |
| 163 | # compiler arguments , we know that will pass |
| 164 | |
| 165 | if (cxx.get_id() == 'gcc' and cxx.version().version_compare('>8.0')) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 166 | add_project_arguments( |
| 167 | cxx.get_supported_arguments([ |
| 168 | '-Wduplicated-cond', |
| 169 | '-Wduplicated-branches', |
| 170 | '-Wlogical-op', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 171 | '-Wnull-dereference', |
Ed Tanous | 079360a | 2022-06-29 10:05:19 -0700 | [diff] [blame] | 172 | '-Wunused-parameter', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 173 | '-Wdouble-promotion', |
Ed Tanous | 8a59281 | 2022-06-04 09:06:59 -0700 | [diff] [blame] | 174 | '-Wshadow', |
Ed Tanous | 30f11eb | 2022-05-25 10:42:15 -0700 | [diff] [blame] | 175 | '-Wno-psabi', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 176 | ]), |
| 177 | language:'cpp') |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 178 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 179 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 180 | if (get_option('buildtype') != 'plain') |
| 181 | if (get_option('b_lto') == true and get_option('optimization')!='0') |
| 182 | # Reduce the binary size by removing unnecessary |
| 183 | # dynamic symbol table entries |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 184 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 185 | add_project_arguments( |
| 186 | cxx.get_supported_arguments([ |
| 187 | '-fno-fat-lto-objects', |
| 188 | '-fvisibility=hidden', |
| 189 | '-fvisibility-inlines-hidden' |
| 190 | ]), |
| 191 | language: 'cpp') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 192 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 193 | if cxx.has_link_argument('-Wl,--exclude-libs,ALL') |
| 194 | add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp') |
George Liu | e820493 | 2021-02-01 14:42:49 +0800 | [diff] [blame] | 195 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 196 | endif |
| 197 | endif |
| 198 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 199 | if( get_option('bmcweb-logging').enabled() or \ |
| 200 | get_option('buildtype').startswith('debug')) |
| 201 | add_project_arguments([ |
| 202 | '-DBMCWEB_ENABLE_LOGGING', |
| 203 | '-DBMCWEB_ENABLE_DEBUG' |
| 204 | ], |
| 205 | language : 'cpp') |
| 206 | |
| 207 | summary({'debug' :'-DBMCWEB_ENABLE_DEBUG', |
| 208 | 'logging' : '-DBMCWEB_ENABLE_LOGGING', |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 209 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 210 | },section : 'Enabled Features') |
| 211 | endif |
| 212 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 213 | # Set Compiler Security flags |
| 214 | |
| 215 | security_flags = [ |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 216 | '-fstack-protector-strong', |
| 217 | '-fPIE', |
| 218 | '-fPIC', |
| 219 | '-D_FORTIFY_SOURCE=2', |
| 220 | '-Wformat', |
| 221 | '-Wformat-security' |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 222 | ] |
| 223 | |
| 224 | ## Add security flags for builds of type 'release','debugoptimized' and 'minsize' |
| 225 | |
| 226 | if not (get_option('buildtype') == 'plain' or get_option('buildtype').startswith('debug')) |
| 227 | add_project_arguments( |
| 228 | cxx.get_supported_arguments([ |
| 229 | security_flags |
| 230 | ]), |
| 231 | language: 'cpp') |
| 232 | endif |
| 233 | |
| 234 | # Boost dependency configuration |
| 235 | |
| 236 | add_project_arguments( |
| 237 | cxx.get_supported_arguments([ |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 238 | '-DBOOST_ALL_NO_LIB', |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 239 | '-DBOOST_ALLOW_DEPRECATED_HEADERS', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 240 | '-DBOOST_ASIO_DISABLE_THREADS', |
| 241 | '-DBOOST_ASIO_NO_DEPRECATED', |
| 242 | '-DBOOST_ASIO_SEPARATE_COMPILATION', |
| 243 | '-DBOOST_BEAST_SEPARATE_COMPILATION', |
Ed Tanous | 9e710e7 | 2022-03-12 17:40:04 -0800 | [diff] [blame] | 244 | '-DBOOST_EXCEPTION_DISABLE', |
Ed Tanous | ab6b6fe | 2022-08-02 20:28:15 -0700 | [diff] [blame] | 245 | '-DBOOST_URL_NO_SOURCE_LOCATION', |
Ed Tanous | 9e710e7 | 2022-03-12 17:40:04 -0800 | [diff] [blame] | 246 | '-DJSON_NOEXCEPTION', |
Ed Tanous | 209aa90 | 2022-08-02 21:11:06 -0700 | [diff] [blame] | 247 | '-DOPENSSL_NO_FILENAMES', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 248 | ]), |
| 249 | language : 'cpp') |
| 250 | |
| 251 | # Find the dependency modules, if not found use meson wrap to get them |
| 252 | # automatically during the configure step |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 253 | bmcweb_dependencies = [] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 254 | |
Nan Zhou | 8682c5a | 2021-11-13 11:00:07 -0800 | [diff] [blame] | 255 | pam = cxx.find_library('pam', required: true) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 256 | atomic = cxx.find_library('atomic', required: true) |
| 257 | openssl = dependency('openssl', required : true) |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 258 | bmcweb_dependencies += [pam, atomic, openssl] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 259 | |
Ed Tanous | 7bb985e | 2021-09-02 14:31:40 -0700 | [diff] [blame] | 260 | sdbusplus = dependency('sdbusplus', required : false, include_type: 'system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 261 | if not sdbusplus.found() |
| 262 | sdbusplus_proj = subproject('sdbusplus', required: true) |
| 263 | sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') |
| 264 | sdbusplus = sdbusplus.as_system('system') |
| 265 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 266 | bmcweb_dependencies += sdbusplus |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 267 | |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 268 | tinyxml = dependency('tinyxml2', |
| 269 | default_options: ['tests=false'], |
| 270 | include_type: 'system', |
| 271 | ) |
| 272 | bmcweb_dependencies += tinyxml |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 273 | |
| 274 | systemd = dependency('systemd') |
| 275 | zlib = dependency('zlib') |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 276 | bmcweb_dependencies += [systemd, zlib] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 277 | |
| 278 | if cxx.has_header('nlohmann/json.hpp') |
| 279 | nlohmann_json = declare_dependency() |
| 280 | else |
Josh Lehan | 259df35 | 2021-10-07 15:20:02 -0700 | [diff] [blame] | 281 | nlohmann_json_proj = subproject('nlohmann', required: true) |
| 282 | nlohmann_json = nlohmann_json_proj.get_variable('nlohmann_json_dep') |
Ed Tanous | b00dcc2 | 2021-02-23 12:52:50 -0800 | [diff] [blame] | 283 | nlohmann_json = nlohmann_json.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 284 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 285 | bmcweb_dependencies += nlohmann_json |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 286 | |
Ed Tanous | 079360a | 2022-06-29 10:05:19 -0700 | [diff] [blame] | 287 | boost = dependency('boost',version : '>=1.81.0', required : false, include_type: 'system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 288 | if not boost.found() |
Ed Tanous | f165dee | 2022-10-25 11:55:49 -0700 | [diff] [blame] | 289 | boost = subproject('boost', required: true).get_variable('boost_dep') |
Ed Tanous | 6c7d53a | 2022-11-02 16:47:45 -0700 | [diff] [blame] | 290 | boost = boost.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 291 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 292 | bmcweb_dependencies += boost |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 293 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 294 | if get_option('tests').enabled() |
| 295 | gtest = dependency('gtest', main: true,disabler: true, required : false) |
| 296 | gmock = dependency('gmock', required : false) |
| 297 | if not gtest.found() and get_option('tests').enabled() |
| 298 | gtest_proj = subproject('gtest', required: true) |
| 299 | gtest = gtest_proj.get_variable('gtest_main_dep') |
| 300 | gmock = gtest_proj.get_variable('gmock_dep') |
| 301 | endif |
Ed Tanous | b00dcc2 | 2021-02-23 12:52:50 -0800 | [diff] [blame] | 302 | gtest = gtest.as_system('system') |
| 303 | gmock = gmock.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 304 | endif |
| 305 | |
Patrick Williams | 6a77993 | 2021-10-12 20:08:44 -0500 | [diff] [blame] | 306 | systemd_system_unit_dir = systemd.get_variable(pkgconfig: 'systemdsystemunitdir') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 307 | |
| 308 | bindir = get_option('prefix') + '/' +get_option('bindir') |
| 309 | |
| 310 | summary({ |
| 311 | 'prefix' : get_option('prefix'), |
| 312 | 'bindir' : bindir, |
| 313 | 'systemd unit directory' : systemd_system_unit_dir |
| 314 | }, section : 'Directories') |
| 315 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 316 | install_subdir('static', install_dir : 'share/www', strip_directory : true) |
| 317 | |
Nan Zhou | 307386e | 2022-10-12 20:29:34 +0000 | [diff] [blame] | 318 | # Config subdirectory |
| 319 | |
| 320 | subdir('config') |
| 321 | bmcweb_dependencies += conf_h_dep |
| 322 | |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 323 | # Source files |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 324 | fs = import('fs') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 325 | |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 326 | srcfiles_bmcweb = files( |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 327 | 'redfish-core/src/error_messages.cpp', |
| 328 | 'redfish-core/src/utils/json_utils.cpp', |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 329 | 'src/boost_asio_ssl.cpp', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 330 | 'src/boost_asio.cpp', |
| 331 | 'src/boost_beast.cpp', |
| 332 | 'src/boost_url.cpp', |
Nan Zhou | 6384e32 | 2022-06-23 22:28:25 +0000 | [diff] [blame] | 333 | 'src/dbus_singleton.cpp', |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 334 | ) |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 335 | |
| 336 | # Generate the bmcweb executable |
| 337 | executable( |
| 338 | 'bmcweb', |
| 339 | srcfiles_bmcweb + ['src/webserver_main.cpp'], |
| 340 | include_directories : incdir, |
| 341 | dependencies: bmcweb_dependencies, |
| 342 | link_args: '-Wl,--gc-sections', |
| 343 | install: true, |
| 344 | install_dir:bindir |
| 345 | ) |
| 346 | |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 347 | srcfiles_unittest = files( |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 348 | 'test/http/crow_getroutes_test.cpp', |
| 349 | 'test/http/router_test.cpp', |
| 350 | 'test/http/utility_test.cpp', |
Ed Tanous | 2c9efc3 | 2022-07-31 22:08:26 -0700 | [diff] [blame] | 351 | 'test/http/verb_test.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 352 | 'test/include/dbus_utility_test.cpp', |
| 353 | 'test/include/google/google_service_root_test.cpp', |
| 354 | 'test/include/http_utility_test.cpp', |
| 355 | 'test/include/human_sort_test.cpp', |
| 356 | 'test/include/ibm/configfile_test.cpp', |
| 357 | 'test/include/ibm/lock_test.cpp', |
| 358 | 'test/include/multipart_test.cpp', |
| 359 | 'test/include/openbmc_dbus_rest_test.cpp', |
| 360 | 'test/redfish-core/include/privileges_test.cpp', |
Carson Labrado | 7e8890c | 2022-11-23 23:58:01 +0000 | [diff] [blame] | 361 | 'test/redfish-core/include/redfish_aggregator_test.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 362 | 'test/redfish-core/include/registries_test.cpp', |
| 363 | 'test/redfish-core/include/utils/hex_utils_test.cpp', |
| 364 | 'test/redfish-core/include/utils/ip_utils_test.cpp', |
| 365 | 'test/redfish-core/include/utils/json_utils_test.cpp', |
| 366 | 'test/redfish-core/include/utils/query_param_test.cpp', |
| 367 | 'test/redfish-core/include/utils/stl_utils_test.cpp', |
| 368 | 'test/redfish-core/include/utils/time_utils_test.cpp', |
| 369 | 'test/redfish-core/lib/chassis_test.cpp', |
Ed Tanous | c71d612 | 2022-11-29 14:10:32 -0800 | [diff] [blame^] | 370 | 'test/redfish-core/lib/sensors_test.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 371 | 'test/redfish-core/lib/log_services_dump_test.cpp', |
| 372 | 'test/redfish-core/lib/service_root_test.cpp', |
| 373 | 'test/redfish-core/lib/thermal_subsystem_test.cpp', |
Chicago Duan | 77b3643 | 2021-02-05 15:48:26 +0800 | [diff] [blame] | 374 | 'test/redfish-core/lib/power_subsystem_test.cpp', |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 375 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 376 | |
| 377 | if(get_option('tests').enabled()) |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 378 | # generate the test executable |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 379 | foreach test_src : srcfiles_unittest |
| 380 | test_bin = executable( |
| 381 | fs.stem(test_src), |
| 382 | srcfiles_bmcweb + test_src, |
| 383 | include_directories : incdir, |
| 384 | install_dir: bindir, |
| 385 | dependencies: bmcweb_dependencies + [ |
| 386 | gtest, |
| 387 | gmock, |
| 388 | ] |
| 389 | ) |
| 390 | test(fs.stem(test_src), test_bin) |
| 391 | endforeach |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 392 | endif |