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