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