Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 1 | project( |
| 2 | 'bmcweb', |
| 3 | 'cpp', |
| 4 | version: '1.0', |
Ed Tanous | 8dc3ddf | 2024-06-25 13:00:16 -0700 | [diff] [blame] | 5 | meson_version: '>=1.3.0', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 6 | default_options: [ |
| 7 | 'b_lto_mode=default', |
| 8 | 'b_lto_threads=0', |
| 9 | 'b_lto=true', |
| 10 | 'b_ndebug=if-release', |
| 11 | 'buildtype=debugoptimized', |
| 12 | 'cpp_rtti=false', |
Patrick Williams | 921cfcd | 2023-08-23 06:31:07 -0500 | [diff] [blame] | 13 | 'cpp_std=c++23', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 14 | 'warning_level=3', |
| 15 | 'werror=true', |
| 16 | ], |
| 17 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 18 | |
| 19 | # Project related links |
| 20 | |
| 21 | project_pretty_name = 'bmcweb' |
| 22 | project_url = 'https://github.com/openbmc/' + project_pretty_name |
| 23 | project_issues_url = project_url + '/issues/new' |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 24 | summary('Issues', project_issues_url, section: 'Report Issues') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 25 | |
| 26 | # Validate the c++ Standard |
| 27 | |
Patrick Williams | 921cfcd | 2023-08-23 06:31:07 -0500 | [diff] [blame] | 28 | if get_option('cpp_std') != 'c++23' |
| 29 | error('This project requires c++23 support') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 30 | endif |
| 31 | |
| 32 | # Get compiler and default build type |
| 33 | |
| 34 | cxx = meson.get_compiler('cpp') |
| 35 | build = get_option('buildtype') |
| 36 | optimization = get_option('optimization') |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 37 | summary('Build Type', build, section: 'Build Info') |
| 38 | summary('Optimization', optimization, section: 'Build Info') |
Ed Tanous | 5e34b67 | 2021-02-05 14:21:27 -0800 | [diff] [blame] | 39 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 40 | # remove debug information for minsize buildtype |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 41 | if (get_option('buildtype') == 'minsize') |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 42 | add_project_arguments( |
| 43 | ['-fdata-sections', '-ffunction-sections'], |
| 44 | language: 'cpp', |
| 45 | ) |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 46 | add_project_arguments('-DNDEBUG', language: 'cpp') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 47 | endif |
| 48 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 49 | if (get_option('dns-resolver') == 'systemd-dbus') |
| 50 | add_project_arguments('-DBMCWEB_DBUS_DNS_RESOLVER', language: 'cpp') |
Ed Tanous | f8ca6d7 | 2022-06-28 12:12:03 -0700 | [diff] [blame] | 51 | endif |
| 52 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 53 | # Disable lto when compiling with no optimization |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 54 | if (get_option('optimization') == '0') |
| 55 | add_project_arguments('-fno-lto', language: 'cpp') |
| 56 | message('Disabling lto & its supported features as optimization is disabled') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 57 | endif |
| 58 | |
| 59 | # Include Directories |
| 60 | |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 61 | incdir = include_directories( |
| 62 | 'include', |
| 63 | 'redfish-core/include', |
| 64 | 'redfish-core/lib', |
| 65 | 'http', |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 66 | ) |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 67 | incdir_cli = include_directories('http', 'include') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 68 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 69 | if (get_option('tests').allowed()) |
Ed Tanous | 25b54db | 2024-04-17 15:40:31 -0700 | [diff] [blame] | 70 | summary('unittest', 'NA', section: 'Features') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 71 | endif |
| 72 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 73 | # Add compiler arguments |
Ed Tanous | 27f5ecf | 2025-02-09 09:46:52 -0800 | [diff] [blame^] | 74 | boost_flags = ['-Wno-unused-parameter'] |
| 75 | nghttp2_flags = [] |
Ed Tanous | ade3f09 | 2024-03-13 13:28:36 -0700 | [diff] [blame] | 76 | if (cxx.get_id() == 'clang') |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 77 | if (cxx.version().version_compare('<17.0')) |
| 78 | error('This project requires clang-17 or higher') |
| 79 | endif |
| 80 | add_project_arguments( |
| 81 | '-Weverything', |
| 82 | '-Wformat=2', |
Ed Tanous | 25991f7 | 2024-06-13 18:10:25 -0700 | [diff] [blame] | 83 | '-Wno-c++20-extensions', |
Ed Tanous | 27f5ecf | 2025-02-09 09:46:52 -0800 | [diff] [blame^] | 84 | '-Wno-c++23-extensions', |
| 85 | '-Wno-c++26-extensions', |
Ed Tanous | b5edf03 | 2025-02-09 09:45:00 -0800 | [diff] [blame] | 86 | '-Wno-c++98-compat', |
| 87 | '-Wno-c++98-compat-pedantic', |
| 88 | '-Wno-covered-switch-default', |
| 89 | '-Wno-disabled-macro-expansion', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 90 | '-Wno-documentation', |
Ed Tanous | b5edf03 | 2025-02-09 09:45:00 -0800 | [diff] [blame] | 91 | '-Wno-documentation-unknown-command', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 92 | '-Wno-exit-time-destructors', |
| 93 | '-Wno-global-constructors', |
Ed Tanous | 27f5ecf | 2025-02-09 09:46:52 -0800 | [diff] [blame^] | 94 | '-Wno-missing-include-dirs', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 95 | '-Wno-newline-eof', |
| 96 | '-Wno-padded', |
| 97 | '-Wno-shadow', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 98 | '-Wno-switch-enum', |
Ed Tanous | 724985f | 2024-06-05 09:19:06 -0700 | [diff] [blame] | 99 | '-Wno-unneeded-internal-declaration', |
Ed Tanous | 60b8de3 | 2024-12-18 11:01:53 -0800 | [diff] [blame] | 100 | '-Wno-unsafe-buffer-usage-in-container', |
Ed Tanous | b5edf03 | 2025-02-09 09:45:00 -0800 | [diff] [blame] | 101 | '-Wno-unused-macros', |
| 102 | '-Wno-used-but-marked-unused', |
| 103 | '-Wno-weak-vtables', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 104 | language: 'cpp', |
| 105 | ) |
Ed Tanous | 27f5ecf | 2025-02-09 09:46:52 -0800 | [diff] [blame^] | 106 | boost_flags += ['-Wno-strict-prototypes', '-Wno-unused-but-set-variable'] |
| 107 | nghttp2_flags += ['-Wno-extra-semi'] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 108 | endif |
| 109 | |
Ed Tanous | ade3f09 | 2024-03-13 13:28:36 -0700 | [diff] [blame] | 110 | if (cxx.get_id() == 'gcc') |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 111 | if (cxx.version().version_compare('<13.0')) |
| 112 | error('This project requires gcc-13 or higher') |
| 113 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 114 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 115 | add_project_arguments( |
| 116 | '-Wformat=2', |
| 117 | '-Wcast-align', |
| 118 | '-Wconversion', |
| 119 | '-Woverloaded-virtual', |
| 120 | '-Wsign-conversion', |
| 121 | '-Wunused', |
| 122 | '-Wduplicated-cond', |
| 123 | '-Wduplicated-branches', |
| 124 | '-Wlogical-op', |
| 125 | '-Wnull-dereference', |
| 126 | '-Wunused-parameter', |
| 127 | '-Wdouble-promotion', |
| 128 | '-Wshadow', |
| 129 | '-Wno-psabi', |
| 130 | '-Wno-attributes', |
| 131 | language: 'cpp', |
| 132 | ) |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 133 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 134 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 135 | if (get_option('buildtype') != 'plain') |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 136 | if (get_option('b_lto') == true and get_option('optimization') != '0') |
| 137 | # Reduce the binary size by removing unnecessary |
| 138 | # dynamic symbol table entries |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 139 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 140 | add_project_arguments( |
| 141 | cxx.get_supported_arguments( |
| 142 | [ |
| 143 | '-fno-fat-lto-objects', |
| 144 | '-fvisibility=hidden', |
| 145 | '-fvisibility-inlines-hidden', |
| 146 | ], |
| 147 | ), |
| 148 | language: 'cpp', |
| 149 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 150 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 151 | if cxx.has_link_argument('-Wl,--exclude-libs,ALL') |
| 152 | add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp') |
| 153 | endif |
George Liu | e820493 | 2021-02-01 14:42:49 +0800 | [diff] [blame] | 154 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 155 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 156 | # Set Compiler Security flags |
| 157 | |
| 158 | security_flags = [ |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 159 | '-fstack-protector-strong', |
| 160 | '-fPIE', |
| 161 | '-fPIC', |
| 162 | '-D_FORTIFY_SOURCE=2', |
| 163 | '-Wformat', |
| 164 | '-Wformat-security', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 165 | ] |
| 166 | |
| 167 | ## Add security flags for builds of type 'release','debugoptimized' and 'minsize' |
| 168 | |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 169 | if not (get_option('buildtype') == 'plain' |
| 170 | or get_option('buildtype').startswith('debug') |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 171 | ) |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 172 | add_project_arguments( |
| 173 | cxx.get_supported_arguments([security_flags]), |
| 174 | language: 'cpp', |
| 175 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 176 | endif |
| 177 | |
| 178 | # Boost dependency configuration |
| 179 | |
| 180 | add_project_arguments( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 181 | cxx.get_supported_arguments( |
| 182 | [ |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 183 | '-DBOOST_ALL_NO_LIB', |
| 184 | '-DBOOST_ALLOW_DEPRECATED_HEADERS', |
| 185 | '-DBOOST_ASIO_DISABLE_THREADS', |
| 186 | '-DBOOST_ASIO_NO_DEPRECATED', |
| 187 | '-DBOOST_ASIO_SEPARATE_COMPILATION', |
| 188 | '-DBOOST_BEAST_SEPARATE_COMPILATION', |
| 189 | '-DBOOST_EXCEPTION_DISABLE', |
| 190 | '-DBOOST_NO_EXCEPTIONS', |
| 191 | '-DBOOST_URL_NO_SOURCE_LOCATION', |
Ed Tanous | f88b217 | 2022-04-15 13:55:05 -0700 | [diff] [blame] | 192 | '-DBOOST_SPIRIT_X3_NO_RTTI', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 193 | '-DJSON_NOEXCEPTION', |
| 194 | '-DOPENSSL_NO_FILENAMES', |
| 195 | '-DSDBUSPLUS_DISABLE_BOOST_COROUTINES', |
| 196 | ], |
| 197 | ), |
| 198 | language: 'cpp', |
| 199 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 200 | |
| 201 | # Find the dependency modules, if not found use meson wrap to get them |
| 202 | # automatically during the configure step |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 203 | bmcweb_dependencies = [] |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 204 | bmcweb_cli_dependencies = [] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 205 | |
Nan Zhou | 8682c5a | 2021-11-13 11:00:07 -0800 | [diff] [blame] | 206 | pam = cxx.find_library('pam', required: true) |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 207 | atomic = cxx.find_library('atomic', required: true) |
Ed Tanous | e792399 | 2023-12-03 14:14:02 -0800 | [diff] [blame] | 208 | bmcweb_dependencies += [pam, atomic] |
| 209 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 210 | openssl = dependency('openssl', required: false, version: '>=3.0.0') |
Ed Tanous | e792399 | 2023-12-03 14:14:02 -0800 | [diff] [blame] | 211 | if not openssl.found() or get_option('b_sanitize') != 'none' |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 212 | openssl_proj = subproject( |
| 213 | 'openssl', |
| 214 | required: true, |
| 215 | default_options: ['warning_level=0', 'werror=false'], |
| 216 | ) |
| 217 | openssl = openssl_proj.get_variable('openssl_dep') |
| 218 | openssl = openssl.as_system('system') |
Ed Tanous | e792399 | 2023-12-03 14:14:02 -0800 | [diff] [blame] | 219 | endif |
| 220 | bmcweb_dependencies += [openssl] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 221 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 222 | nghttp2 = dependency('libnghttp2', version: '>=1.52.0', required: false) |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 223 | if not nghttp2.found() |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 224 | cmake = import('cmake') |
| 225 | opt_var = cmake.subproject_options() |
Ed Tanous | 211cfa4 | 2024-04-17 13:43:14 -0700 | [diff] [blame] | 226 | opt_var.add_cmake_defines( |
Ed Tanous | 27f5ecf | 2025-02-09 09:46:52 -0800 | [diff] [blame^] | 227 | { |
| 228 | 'CMAKE_C_FLAGS': ' '.join(nghttp2_flags), |
| 229 | 'CMAKE_CXX_FLAGS': ' '.join(nghttp2_flags), |
| 230 | 'ENABLE_LIB_ONLY': true, |
| 231 | 'ENABLE_STATIC_LIB': true, |
| 232 | }, |
Ed Tanous | 211cfa4 | 2024-04-17 13:43:14 -0700 | [diff] [blame] | 233 | ) |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 234 | nghttp2_ex = cmake.subproject('nghttp2', options: opt_var) |
Ed Tanous | 211cfa4 | 2024-04-17 13:43:14 -0700 | [diff] [blame] | 235 | nghttp2 = nghttp2_ex.dependency('nghttp2') |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 236 | endif |
| 237 | bmcweb_dependencies += nghttp2 |
| 238 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 239 | sdbusplus = dependency('sdbusplus', required: false, include_type: 'system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 240 | if not sdbusplus.found() |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 241 | sdbusplus_proj = subproject('sdbusplus', required: true) |
| 242 | sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') |
| 243 | sdbusplus = sdbusplus.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 244 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 245 | bmcweb_dependencies += sdbusplus |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 246 | bmcweb_cli_dependencies += sdbusplus |
| 247 | |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 248 | cli11 = dependency('CLI11', required: false, include_type: 'system') |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 249 | if not cli11.found() |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 250 | cli11_proj = subproject('cli11', required: true) |
| 251 | cli11 = cli11_proj.get_variable('CLI11_dep') |
| 252 | cli11 = cli11.as_system('system') |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 253 | endif |
| 254 | bmcweb_cli_dependencies += cli11 |
| 255 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 256 | |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 257 | tinyxml = dependency( |
| 258 | 'tinyxml2', |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 259 | include_type: 'system', |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 260 | version: '>=9.0.0', |
Konstantin Aladyshev | 60e299b | 2024-04-03 11:44:51 +0300 | [diff] [blame] | 261 | default_options: ['tests=false'], |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 262 | ) |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 263 | if not tinyxml.found() |
| 264 | tinyxml_proj = subproject('tinyxml2', required: true) |
| 265 | tinyxml = tinyxml_proj.get_variable('tinyxml_dep') |
| 266 | tinyxml = tinyxml.as_system('system') |
| 267 | endif |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 268 | bmcweb_dependencies += tinyxml |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 269 | |
| 270 | systemd = dependency('systemd') |
Patrick Williams | 058f54e | 2024-09-03 16:07:55 -0400 | [diff] [blame] | 271 | libsystemd = dependency('libsystemd') |
Ed Tanous | 77dcace | 2024-09-07 16:38:05 -0700 | [diff] [blame] | 272 | add_project_arguments( |
| 273 | '-DLIBSYSTEMD_VERSION=' + libsystemd.version(), |
| 274 | language: 'cpp', |
| 275 | ) |
Ed Tanous | 055713e | 2024-07-17 17:19:36 -0700 | [diff] [blame] | 276 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 277 | zlib = dependency('zlib') |
Patrick Williams | 058f54e | 2024-09-03 16:07:55 -0400 | [diff] [blame] | 278 | bmcweb_dependencies += [libsystemd, zlib] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 279 | |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 280 | nlohmann_json_dep = dependency( |
| 281 | 'nlohmann_json', |
Patrick Williams | 0183e47 | 2024-10-10 12:31:07 -0400 | [diff] [blame] | 282 | version: '>=3.11.3', |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 283 | include_type: 'system', |
| 284 | ) |
Patrick Williams | dfd5547 | 2023-12-07 11:50:37 -0600 | [diff] [blame] | 285 | bmcweb_dependencies += nlohmann_json_dep |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 286 | |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 287 | boost = dependency( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 288 | 'boost', |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 289 | modules: ['url'], |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 290 | version: '>=1.84.0', |
| 291 | required: false, |
Ed Tanous | 5e2f099 | 2024-12-02 20:23:51 -0800 | [diff] [blame] | 292 | static: true, |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 293 | include_type: 'system', |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 294 | ) |
Jayanth Othayoth | 90fcc26 | 2024-11-11 06:24:49 -0600 | [diff] [blame] | 295 | |
| 296 | # Boost version is 1.86 or higher to include the 'process' module |
| 297 | if boost.version().version_compare('>=1.86.0') |
| 298 | boost = dependency( |
| 299 | 'boost', |
| 300 | modules: ['url', 'process'], |
| 301 | version: '>=1.86.0', |
Ed Tanous | 5e2f099 | 2024-12-02 20:23:51 -0800 | [diff] [blame] | 302 | static: true, |
Jayanth Othayoth | 90fcc26 | 2024-11-11 06:24:49 -0600 | [diff] [blame] | 303 | required: false, |
| 304 | include_type: 'system', |
| 305 | ) |
| 306 | endif |
| 307 | |
Ed Tanous | 6fd2955 | 2023-10-04 09:40:14 -0700 | [diff] [blame] | 308 | if boost.found() |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 309 | bmcweb_dependencies += [boost] |
| 310 | bmcweb_cli_dependencies += [boost] |
Ed Tanous | 6fd2955 | 2023-10-04 09:40:14 -0700 | [diff] [blame] | 311 | else |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 312 | cmake = import('cmake') |
| 313 | opt = cmake.subproject_options() |
Ed Tanous | f80a87f | 2024-06-16 12:10:33 -0700 | [diff] [blame] | 314 | boost_libs = [ |
| 315 | 'asio', |
| 316 | 'beast', |
| 317 | 'circular_buffer', |
| 318 | 'callable_traits', |
| 319 | 'headers', |
| 320 | 'process', |
| 321 | 'type_index', |
| 322 | 'url', |
| 323 | 'uuid', |
| 324 | 'spirit', |
| 325 | ] |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 326 | opt.add_cmake_defines( |
| 327 | { |
Ed Tanous | 27f5ecf | 2025-02-09 09:46:52 -0800 | [diff] [blame^] | 328 | 'CMAKE_CXX_FLAGS': ' '.join(boost_flags), |
| 329 | 'CMAKE_C_FLAGS': ' '.join(boost_flags), |
Ed Tanous | f80a87f | 2024-06-16 12:10:33 -0700 | [diff] [blame] | 330 | 'BOOST_INCLUDE_LIBRARIES': ';'.join(boost_libs), |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 331 | 'BUILD_SHARED_LIBS': 'OFF', |
| 332 | }, |
| 333 | ) |
Ed Tanous | 144983c | 2024-03-28 00:39:10 -0700 | [diff] [blame] | 334 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 335 | boost = cmake.subproject('boost', required: true, options: opt) |
Ed Tanous | f80a87f | 2024-06-16 12:10:33 -0700 | [diff] [blame] | 336 | foreach boost_lib : boost_libs |
| 337 | boost_lib_instance = boost.dependency('boost_' + boost_lib).as_system() |
| 338 | bmcweb_dependencies += [boost_lib_instance] |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 339 | bmcweb_cli_dependencies += [boost_lib_instance] |
Ed Tanous | f80a87f | 2024-06-16 12:10:33 -0700 | [diff] [blame] | 340 | endforeach |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 341 | endif |
| 342 | |
Patrick Williams | 4efe3e0 | 2023-04-12 08:05:58 -0500 | [diff] [blame] | 343 | systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 344 | |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 345 | bindir = get_option('prefix') + '/' + get_option('bindir') |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 346 | libexec = get_option('prefix') + '/' + get_option('libexecdir') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 347 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 348 | summary( |
| 349 | { |
| 350 | 'prefix': get_option('prefix'), |
| 351 | 'bindir': bindir, |
| 352 | 'systemd unit directory': systemd_system_unit_dir, |
| 353 | }, |
| 354 | section: 'Directories', |
| 355 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 356 | |
Ed Tanous | a529a6a | 2024-05-29 16:51:37 -0700 | [diff] [blame] | 357 | subdir('static') |
| 358 | subdir('redfish-core') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 359 | |
Nan Zhou | 307386e | 2022-10-12 20:29:34 +0000 | [diff] [blame] | 360 | # Config subdirectory |
Nan Zhou | 307386e | 2022-10-12 20:29:34 +0000 | [diff] [blame] | 361 | subdir('config') |
| 362 | bmcweb_dependencies += conf_h_dep |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 363 | bmcweb_cli_dependencies += conf_h_dep |
Nan Zhou | 307386e | 2022-10-12 20:29:34 +0000 | [diff] [blame] | 364 | |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 365 | # Source files |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 366 | fs = import('fs') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 367 | |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 368 | srcfiles_bmcweb = files( |
Ed Tanous | 724985f | 2024-06-05 09:19:06 -0700 | [diff] [blame] | 369 | 'http/mutual_tls.cpp', |
Ed Tanous | beb96b0 | 2025-02-09 09:22:46 -0800 | [diff] [blame] | 370 | 'http/routing/websocketrule.cpp', |
Ed Tanous | b26ff34 | 2024-11-22 11:47:08 -0800 | [diff] [blame] | 371 | 'redfish-core/src/dbus_log_watcher.cpp', |
Ed Tanous | 6c038f2 | 2025-01-14 09:46:04 -0800 | [diff] [blame] | 372 | 'redfish-core/src/error_message_utils.cpp', |
Patrick Williams | 2405091 | 2025-02-01 08:38:29 -0500 | [diff] [blame] | 373 | 'redfish-core/src/error_messages.cpp', |
Alexander Hansen | b80ba2e | 2024-11-18 12:24:35 +0100 | [diff] [blame] | 374 | 'redfish-core/src/event_log.cpp', |
Ed Tanous | 2185dde | 2024-11-22 11:33:51 -0800 | [diff] [blame] | 375 | 'redfish-core/src/filesystem_log_watcher.cpp', |
Ed Tanous | 25991f7 | 2024-06-13 18:10:25 -0700 | [diff] [blame] | 376 | 'redfish-core/src/filter_expr_executor.cpp', |
Ed Tanous | f88b217 | 2022-04-15 13:55:05 -0700 | [diff] [blame] | 377 | 'redfish-core/src/filter_expr_printer.cpp', |
Ed Tanous | a8a5bc1 | 2024-12-02 15:43:16 -0800 | [diff] [blame] | 378 | 'redfish-core/src/heartbeat_messages.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 379 | 'redfish-core/src/redfish.cpp', |
| 380 | 'redfish-core/src/registries.cpp', |
Ed Tanous | a8a5bc1 | 2024-12-02 15:43:16 -0800 | [diff] [blame] | 381 | 'redfish-core/src/resource_messages.cpp', |
Alexander Hansen | 02c1e29 | 2024-11-15 14:30:40 +0100 | [diff] [blame] | 382 | 'redfish-core/src/subscription.cpp', |
Ed Tanous | a8a5bc1 | 2024-12-02 15:43:16 -0800 | [diff] [blame] | 383 | 'redfish-core/src/task_messages.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 384 | 'redfish-core/src/utils/dbus_utils.cpp', |
| 385 | 'redfish-core/src/utils/json_utils.cpp', |
| 386 | 'redfish-core/src/utils/time_utils.cpp', |
| 387 | 'src/boost_asio.cpp', |
| 388 | 'src/boost_asio_ssl.cpp', |
| 389 | 'src/boost_beast.cpp', |
| 390 | 'src/dbus_singleton.cpp', |
Ed Tanous | bb1c7d3 | 2025-02-09 09:39:19 -0800 | [diff] [blame] | 391 | 'src/dbus_utility.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 392 | 'src/json_html_serializer.cpp', |
| 393 | 'src/ossl_random.cpp', |
Ed Tanous | 724985f | 2024-06-05 09:19:06 -0700 | [diff] [blame] | 394 | 'src/ssl_key_handler.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 395 | 'src/webserver_run.cpp', |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 396 | ) |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 397 | |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 398 | bmcweblib = static_library( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 399 | 'bmcweblib', |
| 400 | srcfiles_bmcweb, |
| 401 | include_directories: incdir, |
| 402 | dependencies: bmcweb_dependencies, |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 403 | ) |
| 404 | |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 405 | # Generate the bmcwebd daemon |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 406 | executable( |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 407 | 'bmcwebd', |
| 408 | 'src/webserver_main.cpp', |
| 409 | include_directories: incdir, |
| 410 | dependencies: bmcweb_dependencies, |
| 411 | link_with: bmcweblib, |
| 412 | link_args: '-Wl,--gc-sections', |
| 413 | install: true, |
| 414 | install_dir: libexec, |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 415 | ) |
| 416 | |
| 417 | # Generate the bmcweb CLI application |
| 418 | executable( |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 419 | 'bmcweb', |
| 420 | ['src/webserver_cli.cpp', 'src/boost_asio.cpp'], |
| 421 | include_directories: incdir_cli, |
| 422 | dependencies: bmcweb_cli_dependencies, |
| 423 | install: true, |
| 424 | install_dir: bindir, |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 425 | ) |
| 426 | |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 427 | srcfiles_unittest = files( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 428 | 'test/http/crow_getroutes_test.cpp', |
| 429 | 'test/http/http2_connection_test.cpp', |
| 430 | 'test/http/http_body_test.cpp', |
| 431 | 'test/http/http_connection_test.cpp', |
| 432 | 'test/http/http_response_test.cpp', |
| 433 | 'test/http/mutual_tls.cpp', |
| 434 | 'test/http/mutual_tls_meta.cpp', |
| 435 | 'test/http/parsing_test.cpp', |
| 436 | 'test/http/router_test.cpp', |
| 437 | 'test/http/server_sent_event_test.cpp', |
| 438 | 'test/http/utility_test.cpp', |
| 439 | 'test/http/verb_test.cpp', |
| 440 | 'test/include/async_resolve_test.cpp', |
| 441 | 'test/include/credential_pipe_test.cpp', |
| 442 | 'test/include/dbus_utility_test.cpp', |
| 443 | 'test/include/google/google_service_root_test.cpp', |
| 444 | 'test/include/http_utility_test.cpp', |
| 445 | 'test/include/human_sort_test.cpp', |
| 446 | 'test/include/ibm/configfile_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 447 | 'test/include/json_html_serializer.cpp', |
| 448 | 'test/include/multipart_test.cpp', |
| 449 | 'test/include/openbmc_dbus_rest_test.cpp', |
| 450 | 'test/include/ossl_random.cpp', |
Ed Tanous | 099225c | 2024-03-27 22:03:05 -0700 | [diff] [blame] | 451 | 'test/include/ssl_key_handler_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 452 | 'test/include/str_utility_test.cpp', |
Alexander Hansen | 56431b2 | 2024-12-03 17:19:19 +0100 | [diff] [blame] | 453 | 'test/redfish-core/include/dbus_log_watcher_test.cpp', |
Alexander Hansen | 5494e21 | 2024-11-18 19:21:57 +0100 | [diff] [blame] | 454 | 'test/redfish-core/include/event_log_test.cpp', |
Ed Tanous | d3a48a1 | 2024-09-25 08:58:29 -0700 | [diff] [blame] | 455 | 'test/redfish-core/include/event_matches_filter_test.cpp', |
Ed Tanous | 25991f7 | 2024-06-13 18:10:25 -0700 | [diff] [blame] | 456 | 'test/redfish-core/include/filter_expr_executor_test.cpp', |
Ed Tanous | f88b217 | 2022-04-15 13:55:05 -0700 | [diff] [blame] | 457 | 'test/redfish-core/include/filter_expr_parser_test.cpp', |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 458 | 'test/redfish-core/include/privileges_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 459 | 'test/redfish-core/include/redfish_aggregator_test.cpp', |
Ed Tanous | 6e1a52f | 2024-11-15 19:44:16 -0800 | [diff] [blame] | 460 | 'test/redfish-core/include/redfish_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 461 | 'test/redfish-core/include/registries_test.cpp', |
Ed Tanous | 04adfbc | 2024-12-27 10:55:20 -0800 | [diff] [blame] | 462 | 'test/redfish-core/include/submit_test_event_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 463 | 'test/redfish-core/include/utils/dbus_utils.cpp', |
Patrick Williams | 1e4bc6f | 2025-02-03 14:14:42 -0500 | [diff] [blame] | 464 | 'test/redfish-core/include/utils/error_code_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 465 | 'test/redfish-core/include/utils/hex_utils_test.cpp', |
| 466 | 'test/redfish-core/include/utils/ip_utils_test.cpp', |
| 467 | 'test/redfish-core/include/utils/json_utils_test.cpp', |
| 468 | 'test/redfish-core/include/utils/query_param_test.cpp', |
Janet Adkins | 1516c21 | 2024-08-14 13:22:41 -0500 | [diff] [blame] | 469 | 'test/redfish-core/include/utils/sensor_utils_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 470 | 'test/redfish-core/include/utils/stl_utils_test.cpp', |
| 471 | 'test/redfish-core/include/utils/time_utils_test.cpp', |
| 472 | 'test/redfish-core/lib/chassis_test.cpp', |
Ed Tanous | 6e1a52f | 2024-11-15 19:44:16 -0800 | [diff] [blame] | 473 | 'test/redfish-core/lib/ethernet_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 474 | 'test/redfish-core/lib/log_services_dump_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 475 | 'test/redfish-core/lib/manager_diagnostic_data_test.cpp', |
Ed Tanous | 090ab8e | 2024-05-18 16:07:23 -0700 | [diff] [blame] | 476 | 'test/redfish-core/lib/metadata_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 477 | 'test/redfish-core/lib/power_subsystem_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 478 | 'test/redfish-core/lib/service_root_test.cpp', |
| 479 | 'test/redfish-core/lib/system_test.cpp', |
Ed Tanous | 8d2f868 | 2024-09-03 17:03:29 -0700 | [diff] [blame] | 480 | 'test/redfish-core/lib/systems_logservices_postcode.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 481 | 'test/redfish-core/lib/thermal_subsystem_test.cpp', |
| 482 | 'test/redfish-core/lib/update_service_test.cpp', |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 483 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 484 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 485 | if (get_option('tests').allowed()) |
Ed Tanous | 77dcace | 2024-09-07 16:38:05 -0700 | [diff] [blame] | 486 | gtest = dependency( |
| 487 | 'gtest_main', |
| 488 | main: true, |
| 489 | version: '>=1.15.0', |
| 490 | required: true, |
| 491 | ) |
| 492 | gmock = dependency('gmock', required: true) |
| 493 | gtestlib = static_library('gtestlib', dependencies: [gtest, gmock]) |
| 494 | gtestdep = declare_dependency( |
| 495 | link_with: gtestlib, |
| 496 | dependencies: [ |
| 497 | gtest.partial_dependency(includes: true), |
| 498 | gmock.partial_dependency(includes: true), |
| 499 | ], |
| 500 | ) |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 501 | # generate the test executable |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 502 | foreach test_src : srcfiles_unittest |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 503 | test_bin = executable( |
| 504 | fs.stem(test_src), |
| 505 | test_src, |
| 506 | link_with: bmcweblib, |
| 507 | include_directories: incdir, |
| 508 | install_dir: bindir, |
Ed Tanous | 77dcace | 2024-09-07 16:38:05 -0700 | [diff] [blame] | 509 | dependencies: bmcweb_dependencies + [gtestdep], |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 510 | ) |
Ed Tanous | 77dcace | 2024-09-07 16:38:05 -0700 | [diff] [blame] | 511 | test(fs.stem(test_src), test_bin, protocol: 'gtest') |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 512 | endforeach |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 513 | endif |