Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 3.5 FATAL_ERROR) |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 2 | |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 3 | project (bmc-webserver CXX) |
| 4 | |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 5 | cmake_policy (SET CMP0054 NEW) |
Ed Tanous | cfbe25d | 2017-05-23 16:34:35 -0700 | [diff] [blame] | 6 | |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 7 | set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 8 | |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 9 | option (BUILD_STATIC_LIBS "Built static libraries" ON) |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 10 | |
Joseph Reynolds | 7a777f5 | 2018-11-07 22:01:31 -0600 | [diff] [blame] | 11 | option (YOCTO_DEPENDENCIES "Use YOCTO dependencies system" OFF) |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 12 | |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 13 | option ( |
| 14 | BMCWEB_ENABLE_KVM |
| 15 | "Enable the KVM host video WebSocket. Path is '/kvm/0'. Video is from the |
| 16 | BMC's '/dev/video' device." |
| 17 | ON |
| 18 | ) |
| 19 | option ( |
| 20 | BMCWEB_ENABLE_VM_WEBSOCKET |
| 21 | "Enable the Virtual Media WebSocket. Path is '/vm/0/0'to open the websocket. |
| 22 | See https://github.com/openbmc/jsnbd/blob/master/README." |
| 23 | ON |
| 24 | ) |
| 25 | option ( |
Iwona Klimaszewska | c0a1c8a | 2019-07-12 18:26:38 +0200 | [diff] [blame] | 26 | BMCWEB_ENABLE_VM_NBDPROXY |
| 27 | "Enable the Virtual Media WebSocket." |
| 28 | OFF |
| 29 | ) |
| 30 | option ( |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 31 | BMCWEB_ENABLE_DBUS_REST |
| 32 | "Enable Phosphor REST (D-Bus) APIs. Paths directly map Phosphor D-Bus |
| 33 | object paths, for example, '/xyz/openbmc_project/logging/entry/enumerate'. |
| 34 | See https://github.com/openbmc/docs/blob/master/rest-api.md." |
| 35 | ON |
| 36 | ) |
| 37 | option ( |
| 38 | BMCWEB_ENABLE_REDFISH |
| 39 | "Enable Redfish APIs. Paths are under '/redfish/v1/'. See |
| 40 | https://github.com/openbmc/bmcweb/blob/master/DEVELOPING.md#redfish." |
| 41 | ON |
| 42 | ) |
| 43 | option ( |
| 44 | BMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET |
| 45 | "Enable host serial console WebSocket. Path is '/console0'. See |
| 46 | https://github.com/openbmc/docs/blob/master/console.md." |
| 47 | ON |
| 48 | ) |
| 49 | option ( |
| 50 | BMCWEB_ENABLE_STATIC_HOSTING |
| 51 | "Enable serving files from the '/usr/share/www' directory as paths under |
| 52 | '/'." |
| 53 | ON |
| 54 | ) |
| 55 | option ( |
| 56 | BMCWEB_ENABLE_REDFISH_BMC_JOURNAL |
| 57 | "Enable BMC journal access through Redfish. Paths are under |
| 58 | '/redfish/v1/Managers/bmc/LogServices/Journal'." |
| 59 | OFF |
| 60 | ) |
| 61 | option ( |
| 62 | BMCWEB_ENABLE_REDFISH_RAW_PECI |
| 63 | "Enable PECI transactions through Redfish. Paths are under |
| 64 | '/redfish/v1/Systems/system/LogServices/CpuLog/Actions/Oem/CpuLog.SendRawPeci'." |
| 65 | OFF |
| 66 | ) |
| 67 | option ( |
| 68 | BMCWEB_ENABLE_REDFISH_CPU_LOG |
| 69 | "Enable CPU log service transactions through Redfish. Paths are under |
| 70 | '/redfish/v1/Systems/system/LogServices/Crashdump'." |
| 71 | OFF |
| 72 | ) |
| 73 | option ( |
raviteja-b | c9bb686 | 2020-02-03 11:53:32 -0600 | [diff] [blame] | 74 | BMCWEB_ENABLE_REDFISH_SYSTEMDUMP_LOG |
| 75 | "Enable System dump log service transactions through Redfish. Paths are under |
| 76 | '/redfish/v1/Systems/system/LogServices/SystemDump'." |
| 77 | OFF |
| 78 | ) |
| 79 | option ( |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 80 | BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES |
| 81 | "Enable DBUS log service transactions through Redfish. Paths are under |
| 82 | '/redfish/v1/Systems/system/LogServices/EventLog/Entries'." |
| 83 | OFF |
| 84 | ) |
AppaRao Puli | a634991 | 2019-10-18 17:16:08 +0530 | [diff] [blame] | 85 | option ( |
| 86 | BMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE |
| 87 | "Enable provisioning feature support in redfish. Paths are under |
| 88 | '/redfish/v1/Systems/system/'." |
| 89 | OFF |
| 90 | ) |
Kowalski, Kamil | 55e43f6 | 2019-07-10 13:12:57 +0200 | [diff] [blame] | 91 | option ( |
| 92 | BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION |
| 93 | "Enables authenticating users through TLS client certificates. |
| 94 | The BMCWEB_INSECURE_DISABLE_SSL must be OFF for this option to take effect." |
Zbigniew Kurzynski | cac94c5 | 2019-11-07 12:55:04 +0100 | [diff] [blame] | 95 | ON |
Kowalski, Kamil | 55e43f6 | 2019-07-10 13:12:57 +0200 | [diff] [blame] | 96 | ) |
Ratan Gupta | 453fed0 | 2019-12-14 09:39:47 +0530 | [diff] [blame] | 97 | option ( |
| 98 | BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE |
| 99 | "Enable the IBM management console specific functionality. Paths are under |
| 100 | '/ibm/v1/'." |
| 101 | OFF |
| 102 | ) |
| 103 | |
Ed Tanous | 1da66f7 | 2018-07-27 16:13:37 -0700 | [diff] [blame] | 104 | |
Ed Tanous | bdd1c83 | 2018-10-12 11:00:30 -0700 | [diff] [blame] | 105 | # Insecure options. Every option that starts with a BMCWEB_INSECURE flag should |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 106 | # not be enabled by default for any platform, unless the author fully |
| 107 | # comprehends the implications of doing so. In general, enabling these options |
| 108 | # will cause security problems of varying degrees |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 109 | option ( |
| 110 | BMCWEB_INSECURE_DISABLE_CSRF_PREVENTION |
| 111 | "Disable CSRF prevention checks. Should be set to OFF for production |
| 112 | systems." |
| 113 | OFF |
| 114 | ) |
Ed Tanous | f3d847c | 2017-06-12 16:01:42 -0700 | [diff] [blame] | 115 | |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 116 | option (BMCWEB_INSECURE_DISABLE_SSL |
| 117 | "Disable SSL ports. Should be set to OFF for production systems." OFF) |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 118 | |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 119 | option ( |
| 120 | BMCWEB_INSECURE_DISABLE_AUTHENTICATION |
| 121 | "Disable authentication on all ports. Should be set to OFF for production |
| 122 | systems" |
| 123 | OFF |
| 124 | ) |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 125 | |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 126 | option (BMCWEB_INSECURE_DISABLE_XSS_PREVENTION "Disable XSS preventions" OFF) |
Ed Tanous | 0d485ef | 2017-05-23 09:23:53 -0700 | [diff] [blame] | 127 | |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 128 | option ( |
| 129 | BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE |
| 130 | "Enable TFTP based firmware update transactions through Redfish |
| 131 | UpdateService.SimpleUpdate." |
| 132 | OFF |
| 133 | ) |
Andrew Geissler | 0554c98 | 2019-04-23 14:40:12 -0500 | [diff] [blame] | 134 | |
jayaprakash Mutyala | 91e130a | 2020-03-04 22:26:38 +0000 | [diff] [blame] | 135 | option ( |
AppaRao Puli | b52664e | 2020-04-09 21:36:51 +0530 | [diff] [blame] | 136 | BMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING |
| 137 | "Enable HTTP push style eventing feature" OFF |
| 138 | ) |
| 139 | |
| 140 | option ( |
jayaprakash Mutyala | 91e130a | 2020-03-04 22:26:38 +0000 | [diff] [blame] | 141 | BMCWEB_ENABLE_VALIDATION_UNSECURE_FEATURE |
| 142 | "Enables unsecure features required by validation. Note: must |
| 143 | be turned off for production images." |
| 144 | OFF) |
| 145 | |
| 146 | option ( |
| 147 | BMCWEB_INSECURE_UNRESTRICTED_SENSOR_OVERRIDE |
| 148 | "Enables Sensor override feature without any check." |
| 149 | OFF) |
jayaprakash Mutyala | 70d1d0a | 2020-01-21 23:41:36 +0000 | [diff] [blame] | 150 | |
Adriana Kobylak | 0e1cf26 | 2019-12-05 13:57:57 -0600 | [diff] [blame] | 151 | set (BMCWEB_HTTP_REQ_BODY_LIMIT_MB "30" CACHE STRING |
| 152 | "The max HTTP request body size in MB") |
Kowalski, Kamil | 55e43f6 | 2019-07-10 13:12:57 +0200 | [diff] [blame] | 153 | |
Adriana Kobylak | 0e1cf26 | 2019-12-05 13:57:57 -0600 | [diff] [blame] | 154 | configure_file(config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/config.h) |
Kowalski, Kamil | 55e43f6 | 2019-07-10 13:12:57 +0200 | [diff] [blame] | 155 | |
| 156 | if (BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION AND BMCWEB_INSECURE_DISABLE_SSL) |
| 157 | message("SSL Must be enabled to allow SSL authentication") |
| 158 | set(BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION OFF) |
| 159 | endif() |
| 160 | |
| 161 | |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 162 | include (CTest) |
| 163 | |
Ed Tanous | 6228874 | 2018-10-16 14:58:20 -0700 | [diff] [blame] | 164 | set (CMAKE_CXX_STANDARD 17) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 165 | set (CMAKE_CXX_STANDARD_REQUIRED ON) |
| 166 | |
| 167 | set (CMAKE_EXPORT_COMPILE_COMMANDS ON) |
| 168 | |
Ed Tanous | b01bf29 | 2019-03-25 19:25:26 +0000 | [diff] [blame] | 169 | set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Wall") |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 170 | |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 171 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \ |
| 172 | -fno-rtti \ |
| 173 | ") |
| 174 | |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 175 | set ( |
| 176 | CMAKE_CXX_FLAGS |
| 177 | "${CMAKE_CXX_FLAGS} \ |
Ed Tanous | a9cbc9c | 2019-10-24 09:58:39 -0700 | [diff] [blame] | 178 | -Wall \ |
| 179 | -Wextra \ |
| 180 | -Wnon-virtual-dtor \ |
| 181 | -Wold-style-cast \ |
| 182 | -Wcast-align \ |
| 183 | -Wunused \ |
| 184 | -Woverloaded-virtual \ |
| 185 | -Wpedantic \ |
| 186 | -Wconversion \ |
| 187 | -Wsign-conversion \ |
| 188 | -Wnull-dereference \ |
| 189 | -Wdouble-promotion \ |
| 190 | -Wformat=2 \ |
| 191 | -Wno-unused-parameter \ |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 192 | " |
| 193 | ) |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 194 | |
| 195 | # only set -Werror if we're on a compiler that we know passes |
| 196 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 197 | if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) |
| 198 | set ( |
| 199 | CMAKE_CXX_FLAGS |
| 200 | "${CMAKE_CXX_FLAGS} \ |
Ed Tanous | a9cbc9c | 2019-10-24 09:58:39 -0700 | [diff] [blame] | 201 | -Werror \ |
| 202 | -Wduplicated-cond \ |
| 203 | -Wduplicated-branches \ |
| 204 | -Wlogical-op \ |
| 205 | -Wnull-dereference \ |
| 206 | -Wdouble-promotion \ |
| 207 | -Wformat=2 \ |
| 208 | -Wno-unused-parameter \ |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 209 | " |
| 210 | ) |
| 211 | endif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0) |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 212 | endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
| 213 | |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 214 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti") |
Ed Tanous | 3dac749 | 2017-08-02 13:46:20 -0700 | [diff] [blame] | 215 | |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 216 | # general |
Ed Tanous | 797d0c0 | 2018-08-07 10:22:35 -0700 | [diff] [blame] | 217 | option (BMCWEB_BUILD_UT "Enable Unit test" OFF) |
Ed Tanous | 8041f31 | 2017-04-03 09:47:01 -0700 | [diff] [blame] | 218 | |
Ed Tanous | 1ccd57c | 2017-03-21 13:15:58 -0700 | [diff] [blame] | 219 | # security flags |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 220 | set ( |
| 221 | SECURITY_FLAGS |
| 222 | "-fstack-protector-strong \ |
Ed Tanous | 580f372 | 2018-03-13 16:59:02 -0700 | [diff] [blame] | 223 | -fPIE \ |
| 224 | -fPIC \ |
| 225 | -D_FORTIFY_SOURCE=2 \ |
| 226 | -Wformat \ |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 227 | -Wformat-security" |
Ed Tanous | f0d73c2 | 2018-07-26 14:24:20 -0700 | [diff] [blame] | 228 | ) |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 229 | set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${SECURITY_FLAGS}") |
| 230 | set (CMAKE_CXX_FLAGS_RELWITHDEBINFO |
| 231 | "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${SECURITY_FLAGS}") |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 232 | set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${SECURITY_FLAGS}") |
Ed Tanous | 3dac749 | 2017-08-02 13:46:20 -0700 | [diff] [blame] | 233 | |
Ed Tanous | 580f372 | 2018-03-13 16:59:02 -0700 | [diff] [blame] | 234 | # Enable link time optimization This is a temporary workaround because |
| 235 | # INTERPROCEDURAL_OPTIMIZATION isn't available until cmake 3.9. gcc-ar and gcc- |
| 236 | # ranlib are wrappers around ar and ranlib which add the lto plugin to the |
| 237 | # command line. |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 238 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
| 239 | if (NOT CMAKE_BUILD_TYPE MATCHES Debug) |
| 240 | string (REGEX REPLACE "ar$" "gcc-ar" CMAKE_AR ${CMAKE_AR}) |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 241 | string (REGEX |
| 242 | REPLACE "ranlib$" "gcc-ranlib" CMAKE_RANLIB ${CMAKE_RANLIB}) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 243 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -fno-fat-lto-objects") |
Borawski.Lukasz | 109799e | 2018-01-30 15:04:42 +0100 | [diff] [blame] | 244 | |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 245 | # Reduce the binary size by removing unnecessary dynamic symbol table |
| 246 | # entries |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 247 | set ( |
| 248 | CMAKE_CXX_FLAGS |
| 249 | "${CMAKE_CXX_FLAGS} \ |
Ed Tanous | 580f372 | 2018-03-13 16:59:02 -0700 | [diff] [blame] | 250 | -fvisibility=hidden \ |
| 251 | -fvisibility-inlines-hidden \ |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 252 | -Wl,--exclude-libs,ALL" |
| 253 | ) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 254 | endif (NOT CMAKE_BUILD_TYPE MATCHES Debug) |
| 255 | endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") |
Borawski.Lukasz | 109799e | 2018-01-30 15:04:42 +0100 | [diff] [blame] | 256 | |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 257 | if (NOT ${YOCTO_DEPENDENCIES}) # Download and unpack googletest at configure |
| 258 | # time |
| 259 | configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt) |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 260 | execute_process (COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . |
| 261 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty) |
| 262 | execute_process (COMMAND ${CMAKE_COMMAND} --build . |
| 263 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty) |
Ed tanous | 7d95f5f | 2018-03-23 00:19:20 -0700 | [diff] [blame] | 264 | |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 265 | set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH}) |
| 266 | endif () |
Ed tanous | 7d95f5f | 2018-03-23 00:19:20 -0700 | [diff] [blame] | 267 | |
Ed Tanous | bd81d6a | 2019-10-24 10:00:42 -0700 | [diff] [blame] | 268 | find_package (Boost 1.71 REQUIRED) |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 269 | include_directories (SYSTEM ${BOOST_SRC_DIR}) |
| 270 | |
Ed Tanous | 580f372 | 2018-03-13 16:59:02 -0700 | [diff] [blame] | 271 | # add_definitions(-DBOOST_ASIO_ENABLE_HANDLER_TRACKING) |
Ed Tanous | d3a3806 | 2018-07-27 12:06:29 -0700 | [diff] [blame] | 272 | add_definitions (-DBOOST_ASIO_DISABLE_THREADS) |
Ed Tanous | 39e7750 | 2019-03-04 17:35:53 -0800 | [diff] [blame] | 273 | add_definitions (-DBOOST_BEAST_USE_STD_STRING_VIEW) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 274 | add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) |
| 275 | add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 276 | message (BOOST_VERSION = ${Boost_VERSION}) |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 277 | if ("${Boost_VERSION}" STREQUAL "107100") |
| 278 | add_definitions (-DBOOST_ASIO_NO_DEPRECATED) |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 279 | endif () |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 280 | add_definitions (-DBOOST_ALL_NO_LIB) |
| 281 | add_definitions (-DBOOST_NO_RTTI) |
| 282 | add_definitions (-DBOOST_NO_TYPEID) |
Ed Tanous | c85eb8b | 2018-10-16 14:59:20 -0700 | [diff] [blame] | 283 | add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING) |
Ed tanous | 7d95f5f | 2018-03-23 00:19:20 -0700 | [diff] [blame] | 284 | |
Ed Tanous | aa2e59c | 2018-04-12 12:17:20 -0700 | [diff] [blame] | 285 | # sdbusplus |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 286 | if (NOT ${YOCTO_DEPENDENCIES}) |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 287 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src) |
James Feist | a975e9f | 2018-08-08 14:03:49 -0700 | [diff] [blame] | 288 | link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 289 | endif () |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 290 | |
Ed Tanous | 580f372 | 2018-03-13 16:59:02 -0700 | [diff] [blame] | 291 | # Openssl |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 292 | find_package (OpenSSL REQUIRED) |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 293 | include_directories (SYSTEM ${OPENSSL_INCLUDE_DIR}) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 294 | message ("OPENSSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR}") |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 295 | |
Ed Tanous | 55c7b7a | 2018-05-22 15:27:24 -0700 | [diff] [blame] | 296 | # bmcweb |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 297 | message ("CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") |
| 298 | if (CMAKE_BUILD_TYPE MATCHES Debug) |
| 299 | message ("Logging disabled") |
Ed Tanous | 55c7b7a | 2018-05-22 15:27:24 -0700 | [diff] [blame] | 300 | add_definitions (-DBMCWEB_ENABLE_LOGGING) |
| 301 | add_definitions (-DBMCWEB_ENABLE_DEBUG) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 302 | endif (CMAKE_BUILD_TYPE MATCHES Debug) |
Ed Tanous | aa2e59c | 2018-04-12 12:17:20 -0700 | [diff] [blame] | 303 | |
Andrew Geissler | 1f2fbf2 | 2018-07-17 07:57:30 -0700 | [diff] [blame] | 304 | if (NOT "${BMCWEB_INSECURE_DISABLE_SSL}") |
Ed Tanous | a434f2b | 2018-07-27 13:04:22 -0700 | [diff] [blame] | 305 | add_definitions (-DBMCWEB_ENABLE_SSL) |
Andrew Geissler | 1f2fbf2 | 2018-07-17 07:57:30 -0700 | [diff] [blame] | 306 | endif (NOT "${BMCWEB_INSECURE_DISABLE_SSL}") |
Ed Tanous | c94ad49 | 2019-10-10 15:39:33 -0700 | [diff] [blame] | 307 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/http) |
Ed Tanous | 0fdddb1 | 2017-02-28 11:06:34 -0800 | [diff] [blame] | 308 | |
Ed Tanous | 580f372 | 2018-03-13 16:59:02 -0700 | [diff] [blame] | 309 | # Zlib |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 310 | find_package (ZLIB REQUIRED) |
Ed Tanous | 271584a | 2019-07-09 16:24:22 -0700 | [diff] [blame] | 311 | include_directories (SYSTEM ${ZLIB_INCLUDE_DIRS}) |
Ed Tanous | f927347 | 2017-02-28 16:05:13 -0800 | [diff] [blame] | 312 | |
Ed Tanous | 4758d5b | 2017-06-06 15:28:13 -0700 | [diff] [blame] | 313 | # PAM |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 314 | option (WEBSERVER_ENABLE_PAM "enable pam authentication" ON) |
| 315 | if ("${WEBSERVER_ENABLE_PAM}") |
| 316 | find_package (PAM REQUIRED) |
| 317 | else () |
| 318 | add_definitions ("-DWEBSERVER_DISABLE_PAM") |
| 319 | endif () |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 320 | |
Ed Tanous | f0d73c2 | 2018-07-26 14:24:20 -0700 | [diff] [blame] | 321 | add_definitions ("-Wno-attributes") |
Jennifer Lee | 0334670 | 2018-05-23 14:05:20 -0700 | [diff] [blame] | 322 | # Copy pam-webserver to etc/pam.d |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 323 | install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/pam-webserver DESTINATION /etc/pam.d/ |
| 324 | RENAME webserver) |
Ed Tanous | 5f34a9c | 2017-02-28 12:35:13 -0800 | [diff] [blame] | 325 | |
Ed tanous | 7d95f5f | 2018-03-23 00:19:20 -0700 | [diff] [blame] | 326 | # tinyxml2 |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 327 | find_package (tinyxml2 REQUIRED) |
Ed tanous | 7d95f5f | 2018-03-23 00:19:20 -0700 | [diff] [blame] | 328 | |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 329 | set (WEBSERVER_MAIN src/webserver_main.cpp) |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 330 | |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 331 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 332 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/redfish-core/include) |
Przemyslaw Czarnowski | e13c276 | 2019-09-02 17:32:43 +0200 | [diff] [blame] | 333 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/redfish-core/lib) |
Ed Tanous | b4d29f4 | 2017-03-24 16:39:25 -0700 | [diff] [blame] | 334 | |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 335 | file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/include/bmcweb) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 336 | include_directories (${CMAKE_BINARY_DIR}/include) |
Ed Tanous | 5f34a9c | 2017-02-28 12:35:13 -0800 | [diff] [blame] | 337 | |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 338 | set (SRC_FILES redfish-core/src/error_messages.cpp |
| 339 | redfish-core/src/utils/json_utils.cpp ${GENERATED_SRC_FILES}) |
Ed Tanous | 93f987d | 2017-04-17 17:52:36 -0700 | [diff] [blame] | 340 | |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 341 | file (COPY src/test_resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) |
Ed Tanous | 911ac31 | 2017-08-15 09:37:42 -0700 | [diff] [blame] | 342 | |
Ed Tanous | 38bdb98 | 2017-03-03 14:19:33 -0800 | [diff] [blame] | 343 | # Unit Tests |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 344 | if (${BMCWEB_BUILD_UT}) |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 345 | set (UT_FILES src/crow_test.cpp src/gtest_main.cpp |
| 346 | src/token_authorization_middleware_test.cpp |
| 347 | src/security_headers_middleware_test.cpp src/webassets_test.cpp |
| 348 | src/crow_getroutes_test.cpp src/ast_jpeg_decoder_test.cpp |
| 349 | src/kvm_websocket_test.cpp src/msan_test.cpp |
| 350 | src/ast_video_puller_test.cpp src/openbmc_jtag_rest_test.cpp |
| 351 | redfish-core/ut/privileges_test.cpp |
| 352 | ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp) # big list of naughty |
| 353 | # strings |
| 354 | add_custom_command (OUTPUT ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp |
| 355 | COMMAND |
| 356 | xxd -i |
| 357 | ${CMAKE_CURRENT_SOURCE_DIR}/src/test_resources/blns |
| 358 | ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 359 | |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 360 | set_source_files_properties (${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp |
| 361 | PROPERTIES GENERATED TRUE) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 362 | enable_testing () |
| 363 | |
| 364 | add_executable (webtest ${SRC_FILES} ${UT_FILES}) |
| 365 | |
| 366 | find_package (GTest REQUIRED) |
| 367 | find_package (GMock REQUIRED) |
| 368 | target_link_libraries (webtest ${GTEST_LIBRARIES}) |
| 369 | target_link_libraries (webtest ${GMOCK_LIBRARIES}) |
| 370 | |
| 371 | target_link_libraries (webtest pthread) |
| 372 | target_link_libraries (webtest ${OPENSSL_LIBRARIES}) |
| 373 | target_link_libraries (webtest ${ZLIB_LIBRARIES}) |
| 374 | target_link_libraries (webtest pam) |
| 375 | target_link_libraries (webtest tinyxml2) |
Ed Tanous | d425c6f | 2018-05-16 10:20:11 -0700 | [diff] [blame] | 376 | target_link_libraries (webtest sdbusplus) |
Ed Tanous | e062590 | 2018-05-16 13:35:08 -0700 | [diff] [blame] | 377 | target_link_libraries (webtest -lsystemd) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 378 | target_link_libraries (webtest -lstdc++fs) |
| 379 | add_test (webtest webtest "--gtest_output=xml:webtest.xml") |
| 380 | |
| 381 | endif (${BMCWEB_BUILD_UT}) |
| 382 | |
| 383 | install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/static/ DESTINATION share/www) |
| 384 | |
| 385 | # bmcweb |
| 386 | add_executable (bmcweb ${WEBSERVER_MAIN} ${HDR_FILES} ${SRC_FILES}) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 387 | target_link_libraries (bmcweb ${OPENSSL_LIBRARIES}) |
| 388 | target_link_libraries (bmcweb ${ZLIB_LIBRARIES}) |
| 389 | target_link_libraries (bmcweb pam) |
Brad Bishop | 79ba46f | 2018-11-29 10:57:31 -0500 | [diff] [blame] | 390 | target_link_libraries (bmcweb -latomic) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 391 | target_link_libraries (bmcweb -lsystemd) |
| 392 | target_link_libraries (bmcweb -lstdc++fs) |
Ed Tanous | d425c6f | 2018-05-16 10:20:11 -0700 | [diff] [blame] | 393 | target_link_libraries (bmcweb sdbusplus) |
Ed Tanous | 1e43987 | 2018-05-18 11:48:52 -0700 | [diff] [blame] | 394 | target_link_libraries (bmcweb tinyxml2) |
| 395 | install (TARGETS bmcweb DESTINATION bin) |
| 396 | |
Jason M. Bills | c50fc5a | 2018-11-14 14:49:59 -0800 | [diff] [blame] | 397 | target_compile_definitions ( |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 398 | bmcweb PRIVATE $<$<BOOL:${BMCWEB_ENABLE_KVM}>: -DBMCWEB_ENABLE_KVM> |
Kowalski, Kamil | 55e43f6 | 2019-07-10 13:12:57 +0200 | [diff] [blame] | 399 | $<$<BOOL:${BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION}>: -DBMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION> |
Adriana Kobylak | 1bfbe0e | 2019-01-17 12:08:38 -0600 | [diff] [blame] | 400 | $<$<BOOL:${BMCWEB_ENABLE_VM_WEBSOCKET}>: -DBMCWEB_ENABLE_VM_WEBSOCKET> |
Iwona Klimaszewska | c0a1c8a | 2019-07-12 18:26:38 +0200 | [diff] [blame] | 401 | $<$<BOOL:${BMCWEB_ENABLE_VM_NBDPROXY}>: -DBMCWEB_ENABLE_VM_NBDPROXY> |
Jason M. Bills | c50fc5a | 2018-11-14 14:49:59 -0800 | [diff] [blame] | 402 | $<$<BOOL:${BMCWEB_ENABLE_DBUS_REST}>: -DBMCWEB_ENABLE_DBUS_REST> |
| 403 | $<$<BOOL:${BMCWEB_ENABLE_REDFISH}>: -DBMCWEB_ENABLE_REDFISH> |
| 404 | $<$<BOOL:${BMCWEB_ENABLE_STATIC_HOSTING}>: -DBMCWEB_ENABLE_STATIC_HOSTING> |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 405 | $<$<BOOL:${BMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET}>: |
| 406 | -DBMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET> |
| 407 | $<$<BOOL:${BMCWEB_INSECURE_DISABLE_CSRF_PREVENTION}>: |
| 408 | -DBMCWEB_INSECURE_DISABLE_CSRF_PREVENTION> |
Jason M. Bills | c50fc5a | 2018-11-14 14:49:59 -0800 | [diff] [blame] | 409 | $<$<BOOL:${BMCWEB_INSECURE_DISABLE_SSL}>: -DBMCWEB_INSECURE_DISABLE_SSL> |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 410 | $<$<BOOL:${BMCWEB_INSECURE_DISABLE_XSS_PREVENTION}>: |
| 411 | -DBMCWEB_INSECURE_DISABLE_XSS_PREVENTION> |
| 412 | $<$<BOOL:${BMCWEB_ENABLE_REDFISH_RAW_PECI}>: |
| 413 | -DBMCWEB_ENABLE_REDFISH_RAW_PECI> |
| 414 | $<$<BOOL:${BMCWEB_ENABLE_REDFISH_CPU_LOG}>: |
| 415 | -DBMCWEB_ENABLE_REDFISH_CPU_LOG> |
raviteja-b | c9bb686 | 2020-02-03 11:53:32 -0600 | [diff] [blame] | 416 | $<$<BOOL:${BMCWEB_ENABLE_REDFISH_SYSTEMDUMP_LOG}>: |
| 417 | -DBMCWEB_ENABLE_REDFISH_SYSTEMDUMP_LOG> |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 418 | $<$<BOOL:${BMCWEB_ENABLE_REDFISH_BMC_JOURNAL}>: |
| 419 | -DBMCWEB_ENABLE_REDFISH_BMC_JOURNAL> |
| 420 | $<$<BOOL:${BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES}>: |
| 421 | -DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES> |
| 422 | $<$<BOOL:${BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE}>: |
| 423 | -DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE> |
AppaRao Puli | a634991 | 2019-10-18 17:16:08 +0530 | [diff] [blame] | 424 | $<$<BOOL:${BMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE}>: |
| 425 | -DBMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE> |
jayaprakash Mutyala | 70d1d0a | 2020-01-21 23:41:36 +0000 | [diff] [blame] | 426 | $<$<BOOL:${BMCWEB_ENABLE_VALIDATION_UNSECURE_FEATURE}>: |
| 427 | -DBMCWEB_ENABLE_VALIDATION_UNSECURE_FEATURE> |
jayaprakash Mutyala | 91e130a | 2020-03-04 22:26:38 +0000 | [diff] [blame] | 428 | $<$<BOOL:${BMCWEB_INSECURE_UNRESTRICTED_SENSOR_OVERRIDE}>: |
| 429 | -DBMCWEB_INSECURE_UNRESTRICTED_SENSOR_OVERRIDE> |
Ratan Gupta | 453fed0 | 2019-12-14 09:39:47 +0530 | [diff] [blame] | 430 | $<$<BOOL:${BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE}>: |
| 431 | -DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE> |
AppaRao Puli | b52664e | 2020-04-09 21:36:51 +0530 | [diff] [blame] | 432 | $<$<BOOL:${BMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING}>: |
| 433 | -DBMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING> |
Brad Bishop | f5e906b | 2018-11-29 10:55:10 -0500 | [diff] [blame] | 434 | ) |
Brad Bishop | 5a7094b | 2019-04-10 19:33:15 -0400 | [diff] [blame] | 435 | |
| 436 | # configure and install systemd unit files |
| 437 | configure_file (bmcweb.socket bmcweb.socket COPYONLY) |
| 438 | configure_file (bmcweb.service.in bmcweb.service) |
| 439 | pkg_get_variable (SYSTEMD_SYSTEMUNITDIR systemd systemdsystemunitdir) |
James Feist | 41d1d18 | 2019-10-18 13:57:16 -0700 | [diff] [blame] | 440 | install (FILES ${PROJECT_BINARY_DIR}/bmcweb.socket DESTINATION |
| 441 | ${SYSTEMD_SYSTEMUNITDIR}) |
| 442 | install (FILES ${PROJECT_BINARY_DIR}/bmcweb.service DESTINATION |
| 443 | ${SYSTEMD_SYSTEMUNITDIR}) |