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 |
| 74 | |
Ed Tanous | ade3f09 | 2024-03-13 13:28:36 -0700 | [diff] [blame] | 75 | if (cxx.get_id() == 'clang') |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 76 | if (cxx.version().version_compare('<17.0')) |
| 77 | error('This project requires clang-17 or higher') |
| 78 | endif |
| 79 | add_project_arguments( |
| 80 | '-Weverything', |
| 81 | '-Wformat=2', |
| 82 | '-Wno-c++98-compat-pedantic', |
| 83 | '-Wno-c++98-compat', |
Ed Tanous | 25991f7 | 2024-06-13 18:10:25 -0700 | [diff] [blame] | 84 | '-Wno-c++20-extensions', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 85 | '-Wno-documentation-unknown-command', |
| 86 | '-Wno-documentation', |
| 87 | '-Wno-exit-time-destructors', |
| 88 | '-Wno-global-constructors', |
| 89 | '-Wno-newline-eof', |
| 90 | '-Wno-padded', |
| 91 | '-Wno-shadow', |
| 92 | '-Wno-used-but-marked-unused', |
| 93 | '-Wno-weak-vtables', |
| 94 | '-Wno-switch-enum', |
| 95 | '-Wno-unused-macros', |
| 96 | '-Wno-covered-switch-default', |
Ed Tanous | f88b217 | 2022-04-15 13:55:05 -0700 | [diff] [blame] | 97 | '-Wno-disabled-macro-expansion', |
Ed Tanous | 724985f | 2024-06-05 09:19:06 -0700 | [diff] [blame] | 98 | '-Wno-unneeded-internal-declaration', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 99 | language: 'cpp', |
| 100 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 101 | endif |
| 102 | |
Ed Tanous | ade3f09 | 2024-03-13 13:28:36 -0700 | [diff] [blame] | 103 | if (cxx.get_id() == 'gcc') |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 104 | if (cxx.version().version_compare('<13.0')) |
| 105 | error('This project requires gcc-13 or higher') |
| 106 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 107 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 108 | add_project_arguments( |
| 109 | '-Wformat=2', |
| 110 | '-Wcast-align', |
| 111 | '-Wconversion', |
| 112 | '-Woverloaded-virtual', |
| 113 | '-Wsign-conversion', |
| 114 | '-Wunused', |
| 115 | '-Wduplicated-cond', |
| 116 | '-Wduplicated-branches', |
| 117 | '-Wlogical-op', |
| 118 | '-Wnull-dereference', |
| 119 | '-Wunused-parameter', |
| 120 | '-Wdouble-promotion', |
| 121 | '-Wshadow', |
| 122 | '-Wno-psabi', |
| 123 | '-Wno-attributes', |
| 124 | language: 'cpp', |
| 125 | ) |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 126 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 127 | |
Ed Tanous | c66403c | 2021-09-22 15:28:57 -0700 | [diff] [blame] | 128 | if (get_option('buildtype') != 'plain') |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 129 | if (get_option('b_lto') == true and get_option('optimization') != '0') |
| 130 | # Reduce the binary size by removing unnecessary |
| 131 | # dynamic symbol table entries |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 132 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 133 | add_project_arguments( |
| 134 | cxx.get_supported_arguments( |
| 135 | [ |
| 136 | '-fno-fat-lto-objects', |
| 137 | '-fvisibility=hidden', |
| 138 | '-fvisibility-inlines-hidden', |
| 139 | ], |
| 140 | ), |
| 141 | language: 'cpp', |
| 142 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 143 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 144 | if cxx.has_link_argument('-Wl,--exclude-libs,ALL') |
| 145 | add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp') |
| 146 | endif |
George Liu | e820493 | 2021-02-01 14:42:49 +0800 | [diff] [blame] | 147 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 148 | endif |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 149 | # Set Compiler Security flags |
| 150 | |
| 151 | security_flags = [ |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 152 | '-fstack-protector-strong', |
| 153 | '-fPIE', |
| 154 | '-fPIC', |
| 155 | '-D_FORTIFY_SOURCE=2', |
| 156 | '-Wformat', |
| 157 | '-Wformat-security', |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 158 | ] |
| 159 | |
| 160 | ## Add security flags for builds of type 'release','debugoptimized' and 'minsize' |
| 161 | |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 162 | if not (get_option('buildtype') == 'plain' |
| 163 | or get_option('buildtype').startswith('debug') |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 164 | ) |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 165 | add_project_arguments( |
| 166 | cxx.get_supported_arguments([security_flags]), |
| 167 | language: 'cpp', |
| 168 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 169 | endif |
| 170 | |
| 171 | # Boost dependency configuration |
| 172 | |
| 173 | add_project_arguments( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 174 | cxx.get_supported_arguments( |
| 175 | [ |
| 176 | '-DBOOST_ASIO_DISABLE_CONCEPTS', |
| 177 | '-DBOOST_ALL_NO_LIB', |
| 178 | '-DBOOST_ALLOW_DEPRECATED_HEADERS', |
| 179 | '-DBOOST_ASIO_DISABLE_THREADS', |
| 180 | '-DBOOST_ASIO_NO_DEPRECATED', |
| 181 | '-DBOOST_ASIO_SEPARATE_COMPILATION', |
| 182 | '-DBOOST_BEAST_SEPARATE_COMPILATION', |
| 183 | '-DBOOST_EXCEPTION_DISABLE', |
| 184 | '-DBOOST_NO_EXCEPTIONS', |
| 185 | '-DBOOST_URL_NO_SOURCE_LOCATION', |
Ed Tanous | f88b217 | 2022-04-15 13:55:05 -0700 | [diff] [blame] | 186 | '-DBOOST_SPIRIT_X3_NO_RTTI', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 187 | '-DJSON_NOEXCEPTION', |
| 188 | '-DOPENSSL_NO_FILENAMES', |
| 189 | '-DSDBUSPLUS_DISABLE_BOOST_COROUTINES', |
| 190 | ], |
| 191 | ), |
| 192 | language: 'cpp', |
| 193 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 194 | |
| 195 | # Find the dependency modules, if not found use meson wrap to get them |
| 196 | # automatically during the configure step |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 197 | bmcweb_dependencies = [] |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 198 | bmcweb_cli_dependencies = [] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 199 | |
Nan Zhou | 8682c5a | 2021-11-13 11:00:07 -0800 | [diff] [blame] | 200 | pam = cxx.find_library('pam', required: true) |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 201 | atomic = cxx.find_library('atomic', required: true) |
Ed Tanous | e792399 | 2023-12-03 14:14:02 -0800 | [diff] [blame] | 202 | bmcweb_dependencies += [pam, atomic] |
| 203 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 204 | openssl = dependency('openssl', required: false, version: '>=3.0.0') |
Ed Tanous | e792399 | 2023-12-03 14:14:02 -0800 | [diff] [blame] | 205 | if not openssl.found() or get_option('b_sanitize') != 'none' |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 206 | openssl_proj = subproject( |
| 207 | 'openssl', |
| 208 | required: true, |
| 209 | default_options: ['warning_level=0', 'werror=false'], |
| 210 | ) |
| 211 | openssl = openssl_proj.get_variable('openssl_dep') |
| 212 | openssl = openssl.as_system('system') |
Ed Tanous | e792399 | 2023-12-03 14:14:02 -0800 | [diff] [blame] | 213 | endif |
| 214 | bmcweb_dependencies += [openssl] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 215 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 216 | nghttp2 = dependency('libnghttp2', version: '>=1.52.0', required: false) |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 217 | if not nghttp2.found() |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 218 | cmake = import('cmake') |
| 219 | opt_var = cmake.subproject_options() |
Ed Tanous | 211cfa4 | 2024-04-17 13:43:14 -0700 | [diff] [blame] | 220 | opt_var.add_cmake_defines( |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 221 | {'ENABLE_LIB_ONLY': true, 'ENABLE_STATIC_LIB': true}, |
Ed Tanous | 211cfa4 | 2024-04-17 13:43:14 -0700 | [diff] [blame] | 222 | ) |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 223 | nghttp2_ex = cmake.subproject('nghttp2', options: opt_var) |
Ed Tanous | 211cfa4 | 2024-04-17 13:43:14 -0700 | [diff] [blame] | 224 | nghttp2 = nghttp2_ex.dependency('nghttp2') |
Ed Tanous | fca2cbe | 2021-01-28 14:49:59 -0800 | [diff] [blame] | 225 | endif |
| 226 | bmcweb_dependencies += nghttp2 |
| 227 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 228 | sdbusplus = dependency('sdbusplus', required: false, include_type: 'system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 229 | if not sdbusplus.found() |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 230 | sdbusplus_proj = subproject('sdbusplus', required: true) |
| 231 | sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep') |
| 232 | sdbusplus = sdbusplus.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 233 | endif |
Jason M. Bills | ceb8ddc | 2020-11-23 14:38:39 -0800 | [diff] [blame] | 234 | bmcweb_dependencies += sdbusplus |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 235 | bmcweb_cli_dependencies += sdbusplus |
| 236 | |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 237 | cli11 = dependency('CLI11', required: false, include_type: 'system') |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 238 | if not cli11.found() |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 239 | cli11_proj = subproject('cli11', required: true) |
| 240 | cli11 = cli11_proj.get_variable('CLI11_dep') |
| 241 | cli11 = cli11.as_system('system') |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 242 | endif |
| 243 | bmcweb_cli_dependencies += cli11 |
| 244 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 245 | |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 246 | tinyxml = dependency( |
| 247 | 'tinyxml2', |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 248 | include_type: 'system', |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 249 | version: '>=9.0.0', |
Konstantin Aladyshev | 60e299b | 2024-04-03 11:44:51 +0300 | [diff] [blame] | 250 | default_options: ['tests=false'], |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 251 | ) |
Ed Tanous | c9374ff | 2023-05-26 09:42:08 -0700 | [diff] [blame] | 252 | if not tinyxml.found() |
| 253 | tinyxml_proj = subproject('tinyxml2', required: true) |
| 254 | tinyxml = tinyxml_proj.get_variable('tinyxml_dep') |
| 255 | tinyxml = tinyxml.as_system('system') |
| 256 | endif |
Cody Smith | 3a097b2 | 2022-05-19 14:22:32 -0700 | [diff] [blame] | 257 | bmcweb_dependencies += tinyxml |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 258 | |
| 259 | systemd = dependency('systemd') |
Patrick Williams | 058f54e | 2024-09-03 16:07:55 -0400 | [diff] [blame^] | 260 | libsystemd = dependency('libsystemd') |
| 261 | add_project_arguments('-DLIBSYSTEMD_VERSION=' + libsystemd.version(), language: 'cpp') |
Ed Tanous | 055713e | 2024-07-17 17:19:36 -0700 | [diff] [blame] | 262 | |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 263 | zlib = dependency('zlib') |
Patrick Williams | 058f54e | 2024-09-03 16:07:55 -0400 | [diff] [blame^] | 264 | bmcweb_dependencies += [libsystemd, zlib] |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 265 | |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 266 | nlohmann_json_dep = dependency( |
| 267 | 'nlohmann_json', |
| 268 | version: '>=3.11.2', |
| 269 | include_type: 'system', |
| 270 | ) |
Patrick Williams | dfd5547 | 2023-12-07 11:50:37 -0600 | [diff] [blame] | 271 | bmcweb_dependencies += nlohmann_json_dep |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 272 | |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 273 | boost = dependency( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 274 | 'boost', |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 275 | modules: ['url'], |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 276 | version: '>=1.84.0', |
| 277 | required: false, |
| 278 | include_type: 'system', |
Carson Labrado | 2b5b4da | 2023-10-18 00:02:10 +0000 | [diff] [blame] | 279 | ) |
Ed Tanous | 6fd2955 | 2023-10-04 09:40:14 -0700 | [diff] [blame] | 280 | if boost.found() |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 281 | bmcweb_dependencies += [boost] |
| 282 | bmcweb_cli_dependencies += [boost] |
Ed Tanous | 6fd2955 | 2023-10-04 09:40:14 -0700 | [diff] [blame] | 283 | else |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 284 | cmake = import('cmake') |
| 285 | opt = cmake.subproject_options() |
Ed Tanous | f80a87f | 2024-06-16 12:10:33 -0700 | [diff] [blame] | 286 | boost_libs = [ |
| 287 | 'asio', |
| 288 | 'beast', |
| 289 | 'circular_buffer', |
| 290 | 'callable_traits', |
| 291 | 'headers', |
| 292 | 'process', |
| 293 | 'type_index', |
| 294 | 'url', |
| 295 | 'uuid', |
| 296 | 'spirit', |
| 297 | ] |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 298 | opt.add_cmake_defines( |
| 299 | { |
Ed Tanous | 4ed30a8 | 2024-08-19 11:46:20 -0700 | [diff] [blame] | 300 | # 1.86.0 fails this. Hopefully fixed in 1.86.1 |
| 301 | 'CMAKE_CXX_FLAGS': '-Wno-unused-parameter', |
Ed Tanous | f80a87f | 2024-06-16 12:10:33 -0700 | [diff] [blame] | 302 | 'BOOST_INCLUDE_LIBRARIES': ';'.join(boost_libs), |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 303 | 'BUILD_SHARED_LIBS': 'OFF', |
| 304 | }, |
| 305 | ) |
Ed Tanous | 144983c | 2024-03-28 00:39:10 -0700 | [diff] [blame] | 306 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 307 | boost = cmake.subproject('boost', required: true, options: opt) |
Ed Tanous | f80a87f | 2024-06-16 12:10:33 -0700 | [diff] [blame] | 308 | foreach boost_lib : boost_libs |
| 309 | boost_lib_instance = boost.dependency('boost_' + boost_lib).as_system() |
| 310 | bmcweb_dependencies += [boost_lib_instance] |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 311 | bmcweb_cli_dependencies += [boost_lib_instance] |
Ed Tanous | f80a87f | 2024-06-16 12:10:33 -0700 | [diff] [blame] | 312 | endforeach |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 313 | endif |
| 314 | |
Patrick Williams | 549bed2 | 2023-11-29 06:45:06 -0600 | [diff] [blame] | 315 | if get_option('tests').allowed() |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 316 | gtest = dependency( |
| 317 | 'gtest', |
| 318 | main: true, |
| 319 | version: '>=1.14.0', |
| 320 | disabler: true, |
| 321 | required: false, |
| 322 | ) |
| 323 | gmock = dependency('gmock', required: false) |
| 324 | if not gtest.found() and get_option('tests').allowed() |
| 325 | gtest_proj = subproject('gtest', required: true) |
| 326 | gtest = gtest_proj.get_variable('gtest_main_dep') |
| 327 | gmock = gtest_proj.get_variable('gmock_dep') |
| 328 | endif |
| 329 | gtest = gtest.as_system('system') |
| 330 | gmock = gmock.as_system('system') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 331 | endif |
| 332 | |
Patrick Williams | 4efe3e0 | 2023-04-12 08:05:58 -0500 | [diff] [blame] | 333 | systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 334 | |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 335 | bindir = get_option('prefix') + '/' + get_option('bindir') |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 336 | libexec = get_option('prefix') + '/' + get_option('libexecdir') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 337 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 338 | summary( |
| 339 | { |
| 340 | 'prefix': get_option('prefix'), |
| 341 | 'bindir': bindir, |
| 342 | 'systemd unit directory': systemd_system_unit_dir, |
| 343 | }, |
| 344 | section: 'Directories', |
| 345 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 346 | |
Ed Tanous | a529a6a | 2024-05-29 16:51:37 -0700 | [diff] [blame] | 347 | subdir('static') |
| 348 | subdir('redfish-core') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 349 | |
Nan Zhou | 307386e | 2022-10-12 20:29:34 +0000 | [diff] [blame] | 350 | # Config subdirectory |
Nan Zhou | 307386e | 2022-10-12 20:29:34 +0000 | [diff] [blame] | 351 | subdir('config') |
| 352 | bmcweb_dependencies += conf_h_dep |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 353 | bmcweb_cli_dependencies += conf_h_dep |
Nan Zhou | 307386e | 2022-10-12 20:29:34 +0000 | [diff] [blame] | 354 | |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 355 | # Source files |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 356 | fs = import('fs') |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 357 | |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 358 | srcfiles_bmcweb = files( |
Ed Tanous | 724985f | 2024-06-05 09:19:06 -0700 | [diff] [blame] | 359 | 'http/mutual_tls.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 360 | 'redfish-core/src/error_messages.cpp', |
Ed Tanous | 25991f7 | 2024-06-13 18:10:25 -0700 | [diff] [blame] | 361 | 'redfish-core/src/filter_expr_executor.cpp', |
Ed Tanous | f88b217 | 2022-04-15 13:55:05 -0700 | [diff] [blame] | 362 | 'redfish-core/src/filter_expr_printer.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 363 | 'redfish-core/src/redfish.cpp', |
| 364 | 'redfish-core/src/registries.cpp', |
| 365 | 'redfish-core/src/utils/dbus_utils.cpp', |
| 366 | 'redfish-core/src/utils/json_utils.cpp', |
| 367 | 'redfish-core/src/utils/time_utils.cpp', |
| 368 | 'src/boost_asio.cpp', |
| 369 | 'src/boost_asio_ssl.cpp', |
| 370 | 'src/boost_beast.cpp', |
| 371 | 'src/dbus_singleton.cpp', |
| 372 | 'src/json_html_serializer.cpp', |
| 373 | 'src/ossl_random.cpp', |
Ed Tanous | 724985f | 2024-06-05 09:19:06 -0700 | [diff] [blame] | 374 | 'src/ssl_key_handler.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 375 | 'src/webserver_run.cpp', |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 376 | ) |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 377 | |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 378 | bmcweblib = static_library( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 379 | 'bmcweblib', |
| 380 | srcfiles_bmcweb, |
| 381 | include_directories: incdir, |
| 382 | dependencies: bmcweb_dependencies, |
Ed Tanous | 42bbcd8 | 2023-01-07 18:04:28 -0800 | [diff] [blame] | 383 | ) |
| 384 | |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 385 | # Generate the bmcwebd daemon |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 386 | executable( |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 387 | 'bmcwebd', |
| 388 | 'src/webserver_main.cpp', |
| 389 | include_directories: incdir, |
| 390 | dependencies: bmcweb_dependencies, |
| 391 | link_with: bmcweblib, |
| 392 | link_args: '-Wl,--gc-sections', |
| 393 | install: true, |
| 394 | install_dir: libexec, |
Aushim Nagarkatti | bd1299b | 2024-08-12 17:11:04 -0700 | [diff] [blame] | 395 | ) |
| 396 | |
| 397 | # Generate the bmcweb CLI application |
| 398 | executable( |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 399 | 'bmcweb', |
| 400 | ['src/webserver_cli.cpp', 'src/boost_asio.cpp'], |
| 401 | include_directories: incdir_cli, |
| 402 | dependencies: bmcweb_cli_dependencies, |
| 403 | install: true, |
| 404 | install_dir: bindir, |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 405 | ) |
| 406 | |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 407 | srcfiles_unittest = files( |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 408 | 'test/http/crow_getroutes_test.cpp', |
| 409 | 'test/http/http2_connection_test.cpp', |
| 410 | 'test/http/http_body_test.cpp', |
| 411 | 'test/http/http_connection_test.cpp', |
| 412 | 'test/http/http_response_test.cpp', |
| 413 | 'test/http/mutual_tls.cpp', |
| 414 | 'test/http/mutual_tls_meta.cpp', |
| 415 | 'test/http/parsing_test.cpp', |
| 416 | 'test/http/router_test.cpp', |
| 417 | 'test/http/server_sent_event_test.cpp', |
| 418 | 'test/http/utility_test.cpp', |
| 419 | 'test/http/verb_test.cpp', |
| 420 | 'test/include/async_resolve_test.cpp', |
| 421 | 'test/include/credential_pipe_test.cpp', |
| 422 | 'test/include/dbus_utility_test.cpp', |
| 423 | 'test/include/google/google_service_root_test.cpp', |
| 424 | 'test/include/http_utility_test.cpp', |
| 425 | 'test/include/human_sort_test.cpp', |
| 426 | 'test/include/ibm/configfile_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 427 | 'test/include/json_html_serializer.cpp', |
| 428 | 'test/include/multipart_test.cpp', |
| 429 | 'test/include/openbmc_dbus_rest_test.cpp', |
| 430 | 'test/include/ossl_random.cpp', |
Ed Tanous | 099225c | 2024-03-27 22:03:05 -0700 | [diff] [blame] | 431 | 'test/include/ssl_key_handler_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 432 | 'test/include/str_utility_test.cpp', |
Ed Tanous | 25991f7 | 2024-06-13 18:10:25 -0700 | [diff] [blame] | 433 | 'test/redfish-core/include/filter_expr_executor_test.cpp', |
Ed Tanous | f88b217 | 2022-04-15 13:55:05 -0700 | [diff] [blame] | 434 | 'test/redfish-core/include/filter_expr_parser_test.cpp', |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 435 | 'test/redfish-core/include/privileges_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 436 | 'test/redfish-core/include/redfish_aggregator_test.cpp', |
| 437 | 'test/redfish-core/include/registries_test.cpp', |
| 438 | 'test/redfish-core/include/utils/dbus_utils.cpp', |
| 439 | 'test/redfish-core/include/utils/hex_utils_test.cpp', |
| 440 | 'test/redfish-core/include/utils/ip_utils_test.cpp', |
| 441 | 'test/redfish-core/include/utils/json_utils_test.cpp', |
| 442 | 'test/redfish-core/include/utils/query_param_test.cpp', |
Janet Adkins | 1516c21 | 2024-08-14 13:22:41 -0500 | [diff] [blame] | 443 | 'test/redfish-core/include/utils/sensor_utils_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 444 | 'test/redfish-core/include/utils/stl_utils_test.cpp', |
| 445 | 'test/redfish-core/include/utils/time_utils_test.cpp', |
| 446 | 'test/redfish-core/lib/chassis_test.cpp', |
| 447 | 'test/redfish-core/lib/log_services_dump_test.cpp', |
| 448 | 'test/redfish-core/lib/log_services_test.cpp', |
| 449 | 'test/redfish-core/lib/manager_diagnostic_data_test.cpp', |
Ed Tanous | 090ab8e | 2024-05-18 16:07:23 -0700 | [diff] [blame] | 450 | 'test/redfish-core/lib/metadata_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 451 | 'test/redfish-core/lib/power_subsystem_test.cpp', |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 452 | 'test/redfish-core/lib/service_root_test.cpp', |
| 453 | 'test/redfish-core/lib/system_test.cpp', |
| 454 | 'test/redfish-core/lib/thermal_subsystem_test.cpp', |
| 455 | 'test/redfish-core/lib/update_service_test.cpp', |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 456 | ) |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 457 | |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 458 | if (get_option('tests').allowed()) |
Ed Tanous | 02f1cd9 | 2021-10-27 12:09:06 -0700 | [diff] [blame] | 459 | # generate the test executable |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 460 | foreach test_src : srcfiles_unittest |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 461 | test_bin = executable( |
| 462 | fs.stem(test_src), |
| 463 | test_src, |
| 464 | link_with: bmcweblib, |
| 465 | include_directories: incdir, |
| 466 | install_dir: bindir, |
Ed Tanous | 92e26be | 2024-08-21 13:39:14 -0700 | [diff] [blame] | 467 | dependencies: bmcweb_dependencies + [gtest, gmock], |
Ed Tanous | f2caadc | 2024-01-02 18:34:36 -0800 | [diff] [blame] | 468 | ) |
| 469 | test(fs.stem(test_src), test_bin) |
Nan Zhou | 0ad63df | 2022-10-17 23:03:21 +0000 | [diff] [blame] | 470 | endforeach |
Manojkiran Eda | af6298d | 2020-05-27 08:51:32 +0530 | [diff] [blame] | 471 | endif |