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