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 | |
Ed Tanous | f8ca6d7 | 2022-06-28 12:12:03 -0700 | [diff] [blame] | 44 | if(get_option('dns-resolver') == 'systemd-dbus') |
| 45 | add_project_arguments('-DBMCWEB_DBUS_DNS_RESOLVER', language : 'cpp') |
| 46 | endif |
| 47 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 48 | # Disable lto when compiling with no optimization |
| 49 | if(get_option('optimization') == '0') |
| 50 | add_project_arguments('-fno-lto', language: 'cpp') |
| 51 | message('Disabling lto & its supported features as optimization is disabled') |
| 52 | endif |
| 53 | |
| 54 | # Include Directories |
| 55 | |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 56 | incdir = include_directories( |
| 57 | 'include', |
| 58 | 'redfish-core/include', |
| 59 | 'redfish-core/lib', |
| 60 | 'http' |
| 61 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 62 | |
| 63 | # Get the options and enable the respective features |
| 64 | ## create a MAP of "options : feature_flag" |
| 65 | |
| 66 | feature_map = { |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 67 | 'basic-auth' : '-DBMCWEB_ENABLE_BASIC_AUTHENTICATION', |
| 68 | 'cookie-auth' : '-DBMCWEB_ENABLE_COOKIE_AUTHENTICATION', |
| 69 | 'google-api' : '-DBMCWEB_ENABLE_GOOGLE_API', |
| 70 | 'host-serial-socket' : '-DBMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET', |
| 71 | 'ibm-management-console' : '-DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE', |
Nan Zhou | a43ea82 | 2022-05-27 00:42:44 +0000 | [diff] [blame] | 72 | 'insecure-disable-auth' : '-DBMCWEB_INSECURE_DISABLE_AUTHX', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 73 | 'insecure-disable-csrf' : '-DBMCWEB_INSECURE_DISABLE_CSRF_PREVENTION', |
| 74 | 'insecure-disable-ssl' : '-DBMCWEB_INSECURE_DISABLE_SSL', |
| 75 | 'insecure-push-style-notification' : '-DBMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING', |
| 76 | 'insecure-tftp-update' : '-DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE', |
Ed Tanous | 1aa0c2b | 2022-02-08 12:24:30 +0100 | [diff] [blame] | 77 | 'insecure-ignore-content-type' : '-DBMCWEB_INSECURE_IGNORE_CONTENT_TYPE', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 78 | 'kvm' : '-DBMCWEB_ENABLE_KVM' , |
| 79 | 'mutual-tls-auth' : '-DBMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION', |
Carson Labrado | 7fb3356 | 2022-04-18 23:26:56 +0000 | [diff] [blame] | 80 | 'redfish-aggregation' : '-DBMCWEB_ENABLE_REDFISH_AGGREGATION', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 81 | 'redfish-allow-deprecated-power-thermal' : '-DBMCWEB_ALLOW_DEPRECATED_POWER_THERMAL', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 82 | 'redfish-bmc-journal' : '-DBMCWEB_ENABLE_REDFISH_BMC_JOURNAL', |
| 83 | 'redfish-cpu-log' : '-DBMCWEB_ENABLE_REDFISH_CPU_LOG', |
| 84 | 'redfish-dbus-log' : '-DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES', |
| 85 | 'redfish-dump-log' : '-DBMCWEB_ENABLE_REDFISH_DUMP_LOG', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 86 | 'redfish-host-logger' : '-DBMCWEB_ENABLE_REDFISH_HOST_LOGGER', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 87 | 'redfish-new-powersubsystem-thermalsubsystem' : '-DBMCWEB_NEW_POWERSUBSYSTEM_THERMALSUBSYSTEM', |
Gunnar Mills | 54dce7f | 2022-08-05 17:01:32 +0000 | [diff] [blame] | 88 | 'redfish-oem-manager-fan-data' : '-DBMCWEB_ENABLE_REDFISH_OEM_MANAGER_FAN_DATA', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 89 | 'redfish-provisioning-feature' : '-DBMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE', |
| 90 | 'redfish' : '-DBMCWEB_ENABLE_REDFISH', |
| 91 | 'rest' : '-DBMCWEB_ENABLE_DBUS_REST', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 92 | 'session-auth' : '-DBMCWEB_ENABLE_SESSION_AUTHENTICATION', |
| 93 | 'static-hosting' : '-DBMCWEB_ENABLE_STATIC_HOSTING', |
Ed Tanous | 7f3e84a | 2022-12-28 16:22:54 -0800 | [diff] [blame] | 94 | 'experimental-redfish-multi-computer-system' : '-DBMCWEB_ENABLE_MULTI_COMPUTERSYSTEM', |
Manojkiran Eda | 2d74fbc | 2021-10-28 12:39:49 +0530 | [diff] [blame] | 95 | 'vm-websocket' : '-DBMCWEB_ENABLE_VM_WEBSOCKET', |
| 96 | 'xtoken-auth' : '-DBMCWEB_ENABLE_XTOKEN_AUTHENTICATION', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 97 | #'vm-nbdproxy' : '-DBMCWEB_ENABLE_VM_NBDPROXY', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | # Get the options status and build a project summary to show which flags are |
| 101 | # being enabled during the configuration time. |
| 102 | |
| 103 | foreach option_key,option_value : feature_map |
Patrick Williams | 549bed2 | 2023-11-29 06:45:06 -0600 | [diff] [blame] | 104 | if(get_option(option_key).allowed()) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 105 | if(option_key == 'mutual-tls-auth' or option_key == 'insecure-disable-ssl') |
| 106 | if(get_option('insecure-disable-ssl').disabled() or get_option('mutual-tls-auth').disabled()) |
| 107 | add_project_arguments(option_value,language:'cpp') |
| 108 | summary(option_key,option_value, section : 'Enabled Features') |
| 109 | endif |
Nan Zhou | 3acced2 | 2022-07-12 23:21:02 +0000 | [diff] [blame] | 110 | elif (option_key in ['basic-auth', 'cookie-auth', 'session-auth', 'xtoken-auth', 'mutual-tls-auth']) |
| 111 | if (get_option('insecure-disable-auth').disabled()) |
| 112 | add_project_arguments(option_value, language:'cpp') |
| 113 | summary(option_key,option_value, section : 'Enabled Features') |
| 114 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 115 | else |
| 116 | summary(option_key,option_value, section : 'Enabled Features') |
| 117 | add_project_arguments(option_value,language:'cpp') |
| 118 | endif |
| 119 | else |
| 120 | if(option_key == 'insecure-disable-ssl') |
| 121 | summary('ssl','-DBMCWEB_ENABLE_SSL', section : 'Enabled Features') |
| 122 | add_project_arguments('-DBMCWEB_ENABLE_SSL', language : 'cpp') |
| 123 | endif |
| 124 | endif |
| 125 | endforeach |
| 126 | |
Patrick Williams | 549bed2 | 2023-11-29 06:45:06 -0600 | [diff] [blame] | 127 | if(get_option('tests').allowed()) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 128 | summary('unittest','NA', section : 'Enabled Features') |
| 129 | endif |
| 130 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 131 | # Add compiler arguments |
| 132 | |
Ed Tanous | ade3f09 | 2024-03-13 13:28:36 -0700 | [diff] [blame] | 133 | if (cxx.get_id() == 'clang') |
| 134 | if (cxx.version().version_compare('<17.0')) |
| 135 | error('This project requires clang-17 or higher') |
| 136 | endif |
| 137 | add_project_arguments( |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 138 | '-Weverything', |
Ed Tanous | ade3f09 | 2024-03-13 13:28:36 -0700 | [diff] [blame] | 139 | '-Wformat=2', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 140 | '-Wno-c++98-compat-pedantic', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 141 | '-Wno-c++98-compat', |
| 142 | '-Wno-documentation-unknown-command', |
| 143 | '-Wno-documentation', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 144 | '-Wno-exit-time-destructors', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 145 | '-Wno-global-constructors', |
| 146 | '-Wno-newline-eof', |
| 147 | '-Wno-padded', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 148 | '-Wno-shadow', |
| 149 | '-Wno-used-but-marked-unused', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 150 | '-Wno-weak-vtables', |
Ed Tanous | e6801eb | 2022-12-19 16:11:13 -0800 | [diff] [blame] | 151 | '-Wno-switch-enum', |
Ed Tanous | 72b9076 | 2023-10-31 16:41:16 -0700 | [diff] [blame] | 152 | '-Wno-unused-macros', |
Ed Tanous | 4da0490 | 2024-03-19 11:32:44 -0700 | [diff] [blame] | 153 | '-Wno-covered-switch-default', |
Ed Tanous | ade3f09 | 2024-03-13 13:28:36 -0700 | [diff] [blame] | 154 | language:'cpp') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 155 | endif |
| 156 | |
Ed Tanous | ade3f09 | 2024-03-13 13:28:36 -0700 | [diff] [blame] | 157 | if (cxx.get_id() == 'gcc') |
| 158 | if (cxx.version().version_compare('<13.0')) |
| 159 | error('This project requires gcc-13 or higher') |
| 160 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 161 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 162 | add_project_arguments( |
Ed Tanous | ade3f09 | 2024-03-13 13:28:36 -0700 | [diff] [blame] | 163 | '-Wformat=2', |
| 164 | '-Wcast-align', |
| 165 | '-Wconversion', |
| 166 | '-Woverloaded-virtual', |
| 167 | '-Wsign-conversion', |
| 168 | '-Wunused', |
| 169 | '-Wduplicated-cond', |
| 170 | '-Wduplicated-branches', |
| 171 | '-Wlogical-op', |
| 172 | '-Wnull-dereference', |
| 173 | '-Wunused-parameter', |
| 174 | '-Wdouble-promotion', |
| 175 | '-Wshadow', |
| 176 | '-Wno-psabi', |
| 177 | '-Wno-attributes', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 178 | language:'cpp') |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 179 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 180 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 181 | if (get_option('buildtype') != 'plain') |
| 182 | if (get_option('b_lto') == true and get_option('optimization')!='0') |
| 183 | # Reduce the binary size by removing unnecessary |
| 184 | # dynamic symbol table entries |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 185 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 186 | add_project_arguments( |
| 187 | cxx.get_supported_arguments([ |
| 188 | '-fno-fat-lto-objects', |
| 189 | '-fvisibility=hidden', |
| 190 | '-fvisibility-inlines-hidden' |
| 191 | ]), |
| 192 | language: 'cpp') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 193 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 194 | if cxx.has_link_argument('-Wl,--exclude-libs,ALL') |
| 195 | add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp') |
George Liu | e820493 | 2021-02-01 14:42:49 +0800 | [diff] [blame] | 196 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 197 | endif |
| 198 | endif |
| 199 | |
Myung Bae | 662aa6e | 2023-01-10 14:20:28 -0600 | [diff] [blame] | 200 | if( get_option('bmcweb-logging') != 'disabled' or \ |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 201 | get_option('buildtype').startswith('debug')) |
| 202 | add_project_arguments([ |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 203 | '-DBMCWEB_ENABLE_DEBUG' |
| 204 | ], |
| 205 | language : 'cpp') |
| 206 | |
Myung Bae | 662aa6e | 2023-01-10 14:20:28 -0600 | [diff] [blame] | 207 | summary('debug', '-DBMCWEB_ENABLE_DEBUG', section : 'Enabled Features') |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 208 | endif |
| 209 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 210 | # Set Compiler Security flags |
| 211 | |
| 212 | security_flags = [ |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 213 | '-fstack-protector-strong', |
| 214 | '-fPIE', |
| 215 | '-fPIC', |
| 216 | '-D_FORTIFY_SOURCE=2', |
| 217 | '-Wformat', |
| 218 | '-Wformat-security' |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 219 | ] |
| 220 | |
| 221 | ## Add security flags for builds of type 'release','debugoptimized' and 'minsize' |
| 222 | |
| 223 | if not (get_option('buildtype') == 'plain' or get_option('buildtype').startswith('debug')) |
| 224 | add_project_arguments( |
| 225 | cxx.get_supported_arguments([ |
| 226 | security_flags |
| 227 | ]), |
| 228 | language: 'cpp') |
| 229 | endif |
| 230 | |
| 231 | # Boost dependency configuration |
| 232 | |
| 233 | add_project_arguments( |
| 234 | cxx.get_supported_arguments([ |
Ed Tanous | 6fd2955 | 2023-10-04 09:40:14 -0700 | [diff] [blame] | 235 | '-DBOOST_ASIO_DISABLE_CONCEPTS', |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 236 | '-DBOOST_ALL_NO_LIB', |
Ed Tanous | cf2f932 | 2021-09-22 15:34:41 -0700 | [diff] [blame] | 237 | '-DBOOST_ALLOW_DEPRECATED_HEADERS', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 238 | '-DBOOST_ASIO_DISABLE_THREADS', |
| 239 | '-DBOOST_ASIO_NO_DEPRECATED', |
| 240 | '-DBOOST_ASIO_SEPARATE_COMPILATION', |
| 241 | '-DBOOST_BEAST_SEPARATE_COMPILATION', |
Ed Tanous | 9e710e7 | 2022-03-12 17:40:04 -0800 | [diff] [blame] | 242 | '-DBOOST_EXCEPTION_DISABLE', |
Ed Tanous | f706551 | 2023-05-30 13:00:57 -0700 | [diff] [blame] | 243 | '-DBOOST_NO_EXCEPTIONS', |
Ed Tanous | ab6b6fe | 2022-08-02 20:28:15 -0700 | [diff] [blame] | 244 | '-DBOOST_URL_NO_SOURCE_LOCATION', |
Ed Tanous | 9e710e7 | 2022-03-12 17:40:04 -0800 | [diff] [blame] | 245 | '-DJSON_NOEXCEPTION', |
Ed Tanous | 209aa90 | 2022-08-02 21:11:06 -0700 | [diff] [blame] | 246 | '-DOPENSSL_NO_FILENAMES', |
Ed Tanous | f706551 | 2023-05-30 13:00:57 -0700 | [diff] [blame] | 247 | '-DSDBUSPLUS_DISABLE_BOOST_COROUTINES', |
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) |
Ed Tanous | e792399 | 2023-12-03 14:14:02 -0800 | [diff] [blame] | 257 | bmcweb_dependencies += [pam, atomic] |
| 258 | |
| 259 | openssl = dependency('openssl', required : false, version: '>=3.0.0') |
| 260 | if not openssl.found() or get_option('b_sanitize') != 'none' |
| 261 | openssl_proj = subproject( |
| 262 | 'openssl', |
| 263 | required: true, |
| 264 | default_options: ['warning_level=0', 'werror=false'] |
| 265 | ) |
| 266 | openssl = openssl_proj.get_variable('openssl_dep') |
| 267 | openssl = openssl.as_system('system') |
| 268 | else |
| 269 | # When we build openssl as a subproject, the warnings analyzer starts |
| 270 | # flagging all the C macros as old style casts, so only enable the |
| 271 | # warning for non subprojects. |
| 272 | add_project_arguments('-Wold-style-cast', language: 'cpp') |
| 273 | endif |
| 274 | bmcweb_dependencies += [openssl] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 275 | |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 276 | nghttp2 = dependency('libnghttp2', version: '>=1.52.0', required : false) |
| 277 | if not nghttp2.found() |
| 278 | cmake = import('cmake') |
| 279 | opt_var = cmake.subproject_options() |
| 280 | opt_var.add_cmake_defines({ |
| 281 | 'ENABLE_LIB_ONLY': true, |
| 282 | 'ENABLE_STATIC_LIB': true |
| 283 | }) |
| 284 | nghttp2_ex = cmake.subproject('nghttp2', options: opt_var) |
| 285 | nghttp2 = nghttp2_ex.dependency('nghttp2') |
| 286 | endif |
| 287 | bmcweb_dependencies += nghttp2 |
| 288 | |
Ed Tanous | 7bb985e | 2021-09-02 14:31:40 -0700 | [diff] [blame] | 289 | sdbusplus = dependency('sdbusplus', required : false, include_type: 'system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 290 | if not sdbusplus.found() |
| 291 | sdbusplus_proj = subproject('sdbusplus', required: true) |
| 292 | sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') |
| 293 | sdbusplus = sdbusplus.as_system('system') |
| 294 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 295 | bmcweb_dependencies += sdbusplus |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 296 | |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 297 | tinyxml = dependency( |
| 298 | 'tinyxml2', |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 299 | include_type: 'system', |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 300 | version: '>=9.0.0', |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 301 | ) |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 302 | if not tinyxml.found() |
| 303 | tinyxml_proj = subproject('tinyxml2', required: true) |
| 304 | tinyxml = tinyxml_proj.get_variable('tinyxml_dep') |
| 305 | tinyxml = tinyxml.as_system('system') |
| 306 | endif |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 307 | bmcweb_dependencies += tinyxml |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 308 | |
| 309 | systemd = dependency('systemd') |
| 310 | zlib = dependency('zlib') |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 311 | bmcweb_dependencies += [systemd, zlib] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 312 | |
Patrick Williams | dfd5547 | 2023-12-07 11:50:37 -0600 | [diff] [blame] | 313 | nlohmann_json_dep = dependency('nlohmann_json', version: '>=3.11.2', include_type: 'system') |
| 314 | bmcweb_dependencies += nlohmann_json_dep |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 315 | |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 316 | boost = dependency( |
| 317 | 'boost', |
| 318 | modules: [ |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 319 | 'url', |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 320 | ], |
Ed Tanous | 619b860 | 2024-03-14 11:32:08 -0700 | [diff] [blame] | 321 | version : '>=1.84.0', |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 322 | required : false, |
| 323 | include_type: 'system' |
| 324 | ) |
Ed Tanous | 6fd2955 | 2023-10-04 09:40:14 -0700 | [diff] [blame] | 325 | if boost.found() |
| 326 | bmcweb_dependencies += [boost] |
| 327 | else |
| 328 | cmake = import('cmake') |
| 329 | opt = cmake.subproject_options() |
| 330 | opt.add_cmake_defines({ |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 331 | 'BOOST_INCLUDE_LIBRARIES': 'asio;beast;callable_traits;headers;process;type_index;url;uuid' |
Ed Tanous | 6fd2955 | 2023-10-04 09:40:14 -0700 | [diff] [blame] | 332 | }) |
| 333 | boost = cmake.subproject('boost', required: true, options: opt) |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 334 | boost_asio = boost.dependency('boost_asio').as_system() |
| 335 | boost_beast = boost.dependency('boost_beast').as_system() |
| 336 | boost_callable_traits = boost.dependency('boost_callable_traits').as_system() |
Ed Tanous | 6fd2955 | 2023-10-04 09:40:14 -0700 | [diff] [blame] | 337 | boost_headers = boost.dependency('boost_headers').as_system() |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 338 | boost_process = boost.dependency('boost_process').as_system() |
| 339 | boost_type_index = boost.dependency('boost_type_index').as_system() |
| 340 | boost_url = boost.dependency('boost_url').as_system() |
| 341 | boost_uuid = boost.dependency('boost_uuid').as_system() |
| 342 | bmcweb_dependencies += [ |
| 343 | boost_asio, |
| 344 | boost_beast, |
| 345 | boost_callable_traits, |
| 346 | boost_headers, |
| 347 | boost_process, |
| 348 | boost_type_index, |
| 349 | boost_url, |
| 350 | boost_uuid |
| 351 | ] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 352 | endif |
| 353 | |
Patrick Williams | 549bed2 | 2023-11-29 06:45:06 -0600 | [diff] [blame] | 354 | if get_option('tests').allowed() |
Ed Tanous | 7a6f003 | 2024-01-28 09:49:03 -0800 | [diff] [blame] | 355 | gtest = dependency('gtest', main: true, version: '>=1.14.0', disabler: true, required : false) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 356 | gmock = dependency('gmock', required : false) |
Patrick Williams | 549bed2 | 2023-11-29 06:45:06 -0600 | [diff] [blame] | 357 | if not gtest.found() and get_option('tests').allowed() |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 358 | gtest_proj = subproject('gtest', required: true) |
| 359 | gtest = gtest_proj.get_variable('gtest_main_dep') |
| 360 | gmock = gtest_proj.get_variable('gmock_dep') |
| 361 | endif |
Ed Tanous | b00dcc2 | 2021-02-23 12:52:50 -0800 | [diff] [blame] | 362 | gtest = gtest.as_system('system') |
| 363 | gmock = gmock.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 364 | endif |
| 365 | |
Patrick Williams | 4efe3e0 | 2023-04-12 08:05:58 -0500 | [diff] [blame] | 366 | systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 367 | |
| 368 | bindir = get_option('prefix') + '/' +get_option('bindir') |
| 369 | |
| 370 | summary({ |
| 371 | 'prefix' : get_option('prefix'), |
| 372 | 'bindir' : bindir, |
| 373 | 'systemd unit directory' : systemd_system_unit_dir |
| 374 | }, section : 'Directories') |
| 375 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 376 | install_subdir('static', install_dir : 'share/www', strip_directory : true) |
| 377 | |
Nan Zhou | 307386e | 2022-10-12 20:29:34 +0000 | [diff] [blame] | 378 | # Config subdirectory |
| 379 | |
| 380 | subdir('config') |
| 381 | bmcweb_dependencies += conf_h_dep |
| 382 | |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 383 | # Source files |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 384 | fs = import('fs') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 385 | |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 386 | srcfiles_bmcweb = files( |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 387 | 'redfish-core/src/error_messages.cpp', |
Sui Chen | d1d411f | 2022-04-10 23:09:36 -0700 | [diff] [blame] | 388 | 'redfish-core/src/registries.cpp', |
Ed Tanous | d02aad3 | 2024-02-13 14:43:34 -0800 | [diff] [blame] | 389 | 'redfish-core/src/utils/dbus_utils.cpp', |
Ed Tanous | 1b8b02a | 2023-01-08 12:35:35 -0800 | [diff] [blame] | 390 | 'redfish-core/src/utils/time_utils.cpp', |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 391 | 'redfish-core/src/utils/json_utils.cpp', |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 392 | 'src/boost_asio_ssl.cpp', |
Ed Tanous | f523c32 | 2021-12-03 10:46:48 -0800 | [diff] [blame] | 393 | 'src/boost_asio.cpp', |
| 394 | 'src/boost_beast.cpp', |
Nan Zhou | 6384e32 | 2022-06-23 22:28:25 +0000 | [diff] [blame] | 395 | 'src/dbus_singleton.cpp', |
Ed Tanous | 61e349a | 2023-05-31 11:57:43 -0700 | [diff] [blame] | 396 | 'src/json_html_serializer.cpp', |
Ed Tanous | 2c6ffdb | 2023-06-28 11:28:38 -0700 | [diff] [blame] | 397 | 'src/ossl_random.cpp', |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 398 | ) |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 399 | |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 400 | bmcweblib = static_library( |
| 401 | 'bmcweblib', |
| 402 | srcfiles_bmcweb, |
| 403 | include_directories : incdir, |
| 404 | dependencies: bmcweb_dependencies, |
| 405 | ) |
| 406 | |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 407 | # Generate the bmcweb executable |
| 408 | executable( |
| 409 | 'bmcweb', |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 410 | 'src/webserver_main.cpp', |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 411 | include_directories : incdir, |
| 412 | dependencies: bmcweb_dependencies, |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 413 | link_with: bmcweblib, |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 414 | link_args: '-Wl,--gc-sections', |
| 415 | install: true, |
| 416 | install_dir:bindir |
| 417 | ) |
| 418 | |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 419 | srcfiles_unittest = files( |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 420 | 'test/http/crow_getroutes_test.cpp', |
Ed Tanous | 52dd693 | 2024-01-29 08:34:59 -0800 | [diff] [blame] | 421 | 'test/http/http2_connection_test.cpp', |
Ed Tanous | 4fa45df | 2023-09-01 14:20:50 -0700 | [diff] [blame] | 422 | 'test/http/http_connection_test.cpp', |
Ed Tanous | e792399 | 2023-12-03 14:14:02 -0800 | [diff] [blame] | 423 | 'test/http/mutual_tls.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 424 | 'test/http/router_test.cpp', |
Ed Tanous | 1fccd0d | 2024-03-19 09:16:16 -0700 | [diff] [blame] | 425 | 'test/http/parsing_test.cpp', |
Abhilash Raju | 8e3f703 | 2023-07-17 08:53:11 -0500 | [diff] [blame] | 426 | 'test/http/http_response_test.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 427 | 'test/http/utility_test.cpp', |
Ed Tanous | 2c9efc3 | 2022-07-31 22:08:26 -0700 | [diff] [blame] | 428 | 'test/http/verb_test.cpp', |
Ed Tanous | 8f79c5b | 2024-01-30 15:56:37 -0800 | [diff] [blame] | 429 | 'test/http/server_sent_event_test.cpp', |
Marco Kawajiri | 0e373b5 | 2023-10-31 13:36:58 -0700 | [diff] [blame] | 430 | 'test/http/mutual_tls_meta.cpp', |
Ed Tanous | b289614 | 2024-01-31 15:25:47 -0800 | [diff] [blame] | 431 | 'test/http/http_body_test.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 432 | 'test/include/dbus_utility_test.cpp', |
| 433 | 'test/include/google/google_service_root_test.cpp', |
Ed Tanous | 5a60c56 | 2023-05-18 13:52:34 -0700 | [diff] [blame] | 434 | 'test/include/json_html_serializer.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 435 | 'test/include/http_utility_test.cpp', |
| 436 | 'test/include/human_sort_test.cpp', |
Ed Tanous | e1452be | 2021-10-04 17:03:52 -0700 | [diff] [blame] | 437 | 'test/include/async_resolve_test.cpp', |
Ed Tanous | 11e8f60 | 2023-08-24 14:25:18 -0700 | [diff] [blame] | 438 | 'test/include/credential_pipe_test.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 439 | 'test/include/ibm/configfile_test.cpp', |
| 440 | 'test/include/ibm/lock_test.cpp', |
| 441 | 'test/include/multipart_test.cpp', |
| 442 | 'test/include/openbmc_dbus_rest_test.cpp', |
Ed Tanous | 50ebd4a | 2023-01-19 19:03:17 -0800 | [diff] [blame] | 443 | 'test/include/str_utility_test.cpp', |
Ed Tanous | 2c6ffdb | 2023-06-28 11:28:38 -0700 | [diff] [blame] | 444 | 'test/include/ossl_random.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 445 | 'test/redfish-core/include/privileges_test.cpp', |
Carson Labrado | 7e8890c | 2022-11-23 23:58:01 +0000 | [diff] [blame] | 446 | 'test/redfish-core/include/redfish_aggregator_test.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 447 | 'test/redfish-core/include/registries_test.cpp', |
| 448 | 'test/redfish-core/include/utils/hex_utils_test.cpp', |
Ed Tanous | d02aad3 | 2024-02-13 14:43:34 -0800 | [diff] [blame] | 449 | 'test/redfish-core/include/utils/dbus_utils.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 450 | 'test/redfish-core/include/utils/ip_utils_test.cpp', |
| 451 | 'test/redfish-core/include/utils/json_utils_test.cpp', |
| 452 | 'test/redfish-core/include/utils/query_param_test.cpp', |
| 453 | 'test/redfish-core/include/utils/stl_utils_test.cpp', |
| 454 | 'test/redfish-core/include/utils/time_utils_test.cpp', |
| 455 | 'test/redfish-core/lib/chassis_test.cpp', |
Ed Tanous | c71d612 | 2022-11-29 14:10:32 -0800 | [diff] [blame] | 456 | 'test/redfish-core/lib/sensors_test.cpp', |
Andrew Geissler | 33e1f12 | 2024-02-26 21:10:16 -0600 | [diff] [blame] | 457 | 'test/redfish-core/lib/system_test.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 458 | 'test/redfish-core/lib/log_services_dump_test.cpp', |
Myung Bae | 75e8e21 | 2023-11-30 12:53:46 -0800 | [diff] [blame] | 459 | 'test/redfish-core/lib/log_services_test.cpp', |
Ed Tanous | f86bcc8 | 2023-08-25 09:34:07 -0700 | [diff] [blame] | 460 | 'test/redfish-core/lib/update_service_test.cpp', |
Nan Zhou | c33a039 | 2022-09-10 18:11:41 +0000 | [diff] [blame] | 461 | 'test/redfish-core/lib/service_root_test.cpp', |
| 462 | 'test/redfish-core/lib/thermal_subsystem_test.cpp', |
Chicago Duan | 77b3643 | 2021-02-05 15:48:26 +0800 | [diff] [blame] | 463 | 'test/redfish-core/lib/power_subsystem_test.cpp', |
Jagpal Singh Gill | e610b31 | 2023-12-20 15:35:41 -0800 | [diff] [blame] | 464 | 'test/redfish-core/lib/manager_diagnostic_data_test.cpp', |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 465 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 466 | |
Ed Tanous | e792399 | 2023-12-03 14:14:02 -0800 | [diff] [blame] | 467 | |
Patrick Williams | 549bed2 | 2023-11-29 06:45:06 -0600 | [diff] [blame] | 468 | if(get_option('tests').allowed()) |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 469 | # generate the test executable |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 470 | foreach test_src : srcfiles_unittest |
| 471 | test_bin = executable( |
| 472 | fs.stem(test_src), |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 473 | test_src, |
| 474 | link_with: bmcweblib, |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 475 | include_directories : incdir, |
| 476 | install_dir: bindir, |
| 477 | dependencies: bmcweb_dependencies + [ |
| 478 | gtest, |
| 479 | gmock, |
| 480 | ] |
| 481 | ) |
| 482 | test(fs.stem(test_src), test_bin) |
| 483 | endforeach |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 484 | endif |