blob: 62e1b143923e6f4498c1dbacb92b9e39931f0396 [file] [log] [blame]
Ed Tanous1e439872018-05-18 11:48:52 -07001cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
Ed Tanous0fdddb12017-02-28 11:06:34 -08002
Ed Tanous271584a2019-07-09 16:24:22 -07003project (bmc-webserver CXX)
4
Ed Tanous1e439872018-05-18 11:48:52 -07005cmake_policy (SET CMP0054 NEW)
Ed Tanouscfbe25d2017-05-23 16:34:35 -07006
Ed Tanous1e439872018-05-18 11:48:52 -07007set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
Ed Tanous0fdddb12017-02-28 11:06:34 -08008
Ed Tanous1e439872018-05-18 11:48:52 -07009option (BUILD_STATIC_LIBS "Built static libraries" ON)
Ed Tanous911ac312017-08-15 09:37:42 -070010
Joseph Reynolds7a777f52018-11-07 22:01:31 -060011option (YOCTO_DEPENDENCIES "Use YOCTO dependencies system" OFF)
Ed Tanous0fdddb12017-02-28 11:06:34 -080012
James Feist41d1d182019-10-18 13:57:16 -070013option (
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)
19option (
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)
25option (
Iwona Klimaszewskac0a1c8a2019-07-12 18:26:38 +020026 BMCWEB_ENABLE_VM_NBDPROXY
27 "Enable the Virtual Media WebSocket."
28 OFF
29)
30option (
James Feist41d1d182019-10-18 13:57:16 -070031 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)
37option (
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)
43option (
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)
49option (
50 BMCWEB_ENABLE_STATIC_HOSTING
51 "Enable serving files from the '/usr/share/www' directory as paths under
52 '/'."
53 ON
54)
55option (
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)
61option (
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)
67option (
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)
73option (
Asmitha Karunanithi5cb1dd22020-05-07 04:35:02 -050074 BMCWEB_ENABLE_REDFISH_DUMP_LOG
75 "Enable BMC and System dump log service transactions through Redfish. For BMC dump, paths
76 are under '/redfish/v1/Managers/bmc/LogServices/Dump' and for System dump,
77 paths are under '/redfish/v1/Systems/system/LogServices/Dump'."
raviteja-bc9bb6862020-02-03 11:53:32 -060078 OFF
79)
80option (
James Feist41d1d182019-10-18 13:57:16 -070081 BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES
82 "Enable DBUS log service transactions through Redfish. Paths are under
83 '/redfish/v1/Systems/system/LogServices/EventLog/Entries'."
84 OFF
85)
AppaRao Pulia6349912019-10-18 17:16:08 +053086option (
87 BMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE
88 "Enable provisioning feature support in redfish. Paths are under
89 '/redfish/v1/Systems/system/'."
90 OFF
91)
Kowalski, Kamil55e43f62019-07-10 13:12:57 +020092option (
93 BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION
94 "Enables authenticating users through TLS client certificates.
95 The BMCWEB_INSECURE_DISABLE_SSL must be OFF for this option to take effect."
Zbigniew Kurzynskicac94c52019-11-07 12:55:04 +010096 ON
Kowalski, Kamil55e43f62019-07-10 13:12:57 +020097)
Ratan Gupta453fed02019-12-14 09:39:47 +053098option (
99 BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE
100 "Enable the IBM management console specific functionality. Paths are under
101 '/ibm/v1/'."
102 OFF
103)
104
Ed Tanous1da66f72018-07-27 16:13:37 -0700105
Ed Tanousbdd1c832018-10-12 11:00:30 -0700106# Insecure options. Every option that starts with a BMCWEB_INSECURE flag should
Ed Tanous1e439872018-05-18 11:48:52 -0700107# not be enabled by default for any platform, unless the author fully
108# comprehends the implications of doing so. In general, enabling these options
109# will cause security problems of varying degrees
James Feist41d1d182019-10-18 13:57:16 -0700110option (
111 BMCWEB_INSECURE_DISABLE_CSRF_PREVENTION
112 "Disable CSRF prevention checks. Should be set to OFF for production
113 systems."
114 OFF
115)
Ed Tanousf3d847c2017-06-12 16:01:42 -0700116
James Feist41d1d182019-10-18 13:57:16 -0700117option (BMCWEB_INSECURE_DISABLE_SSL
118 "Disable SSL ports. Should be set to OFF for production systems." OFF)
Ed Tanous0fdddb12017-02-28 11:06:34 -0800119
James Feist41d1d182019-10-18 13:57:16 -0700120option (
121 BMCWEB_INSECURE_DISABLE_AUTHENTICATION
122 "Disable authentication on all ports. Should be set to OFF for production
123 systems"
124 OFF
125)
Ed Tanous0fdddb12017-02-28 11:06:34 -0800126
Ed Tanous1e439872018-05-18 11:48:52 -0700127option (BMCWEB_INSECURE_DISABLE_XSS_PREVENTION "Disable XSS preventions" OFF)
Ed Tanous0d485ef2017-05-23 09:23:53 -0700128
James Feist41d1d182019-10-18 13:57:16 -0700129option (
130 BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE
131 "Enable TFTP based firmware update transactions through Redfish
132 UpdateService.SimpleUpdate."
133 OFF
134)
Andrew Geissler0554c982019-04-23 14:40:12 -0500135
jayaprakash Mutyala91e130a2020-03-04 22:26:38 +0000136option (
AppaRao Pulib52664e2020-04-09 21:36:51 +0530137 BMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING
138 "Enable HTTP push style eventing feature" OFF
139)
140
141option (
jayaprakash Mutyala91e130a2020-03-04 22:26:38 +0000142 BMCWEB_ENABLE_VALIDATION_UNSECURE_FEATURE
143 "Enables unsecure features required by validation. Note: must
144 be turned off for production images."
145 OFF)
146
147option (
148 BMCWEB_INSECURE_UNRESTRICTED_SENSOR_OVERRIDE
149 "Enables Sensor override feature without any check."
150 OFF)
jayaprakash Mutyala70d1d0a2020-01-21 23:41:36 +0000151
Adriana Kobylak0e1cf262019-12-05 13:57:57 -0600152set (BMCWEB_HTTP_REQ_BODY_LIMIT_MB "30" CACHE STRING
153 "The max HTTP request body size in MB")
Kowalski, Kamil55e43f62019-07-10 13:12:57 +0200154
Adriana Kobylak0e1cf262019-12-05 13:57:57 -0600155configure_file(config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/include/config.h)
Kowalski, Kamil55e43f62019-07-10 13:12:57 +0200156
157if (BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION AND BMCWEB_INSECURE_DISABLE_SSL)
158 message("SSL Must be enabled to allow SSL authentication")
159 set(BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION OFF)
160endif()
161
162
Ed Tanous1e439872018-05-18 11:48:52 -0700163include (CTest)
164
Ed Tanous62288742018-10-16 14:58:20 -0700165set (CMAKE_CXX_STANDARD 17)
Ed Tanous1e439872018-05-18 11:48:52 -0700166set (CMAKE_CXX_STANDARD_REQUIRED ON)
167
168set (CMAKE_EXPORT_COMPILE_COMMANDS ON)
169
Ed Tanousb01bf292019-03-25 19:25:26 +0000170set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Wall")
Ed Tanous1e439872018-05-18 11:48:52 -0700171
Ed Tanousd4d77e32020-08-18 00:07:28 -0700172# reenable when https://github.com/chriskohlhoff/asio/issues/533
173# is resolved. ASIO default executor doesn't build with no-rtti
174#set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} \
175# -fno-rtti \
176#")
Ed Tanous271584a2019-07-09 16:24:22 -0700177
James Feist41d1d182019-10-18 13:57:16 -0700178set (
179 CMAKE_CXX_FLAGS
180 "${CMAKE_CXX_FLAGS} \
Ed Tanousa9cbc9c2019-10-24 09:58:39 -0700181 -Wall \
182 -Wextra \
183 -Wnon-virtual-dtor \
184 -Wold-style-cast \
185 -Wcast-align \
186 -Wunused \
187 -Woverloaded-virtual \
188 -Wpedantic \
189 -Wconversion \
190 -Wsign-conversion \
191 -Wnull-dereference \
192 -Wdouble-promotion \
193 -Wformat=2 \
James Feist41d1d182019-10-18 13:57:16 -0700194"
195)
Ed Tanous271584a2019-07-09 16:24:22 -0700196
197# only set -Werror if we're on a compiler that we know passes
198if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
James Feist41d1d182019-10-18 13:57:16 -0700199 if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
200 set (
201 CMAKE_CXX_FLAGS
202 "${CMAKE_CXX_FLAGS} \
Ed Tanousa9cbc9c2019-10-24 09:58:39 -0700203 -Werror \
204 -Wduplicated-cond \
205 -Wduplicated-branches \
206 -Wlogical-op \
207 -Wnull-dereference \
208 -Wdouble-promotion \
209 -Wformat=2 \
Ed Tanouscb13a392020-07-25 19:02:03 +0000210 -Wunused-parameter \
James Feist41d1d182019-10-18 13:57:16 -0700211 "
212 )
213 endif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
Ed Tanous271584a2019-07-09 16:24:22 -0700214endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
215
Ed Tanous23a21a12020-07-25 04:45:05 +0000216if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
217 if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 9.0)
218 set (
219 CMAKE_CXX_FLAGS
220 "${CMAKE_CXX_FLAGS} \
221 -Werror \
222 -Weverything \
223 -Wno-c++98-compat \
224 -Wno-c++98-compat-pedantic \
225 -Wno-global-constructors \
226 -Wno-exit-time-destructors \
227 -Wno-shadow \
228 -Wno-used-but-marked-unused \
229 -Wno-documentation-unknown-command \
230 -Wno-weak-vtables \
231 -Wno-documentation \
232 -Wno-padded \
Ed Tanouscb13a392020-07-25 19:02:03 +0000233 -Wunused-parameter \
Ed Tanous23a21a12020-07-25 04:45:05 +0000234 -Wcovered-switch-default \
235 -Wcomma \
236 -Wextra-semi \
237 -Wzero-as-null-pointer-constant \
238 -Wswitch-enum \
239 -Wnull-dereference \
240 -Wdouble-promotion \
241 -Wformat=2 \
242 "
243 )
244 endif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
245endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
Ed Tanous1e439872018-05-18 11:48:52 -0700246set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti")
Ed Tanous3dac7492017-08-02 13:46:20 -0700247
Ed Tanous0fdddb12017-02-28 11:06:34 -0800248# general
Ed Tanous797d0c02018-08-07 10:22:35 -0700249option (BMCWEB_BUILD_UT "Enable Unit test" OFF)
Ed Tanous8041f312017-04-03 09:47:01 -0700250
Ed Tanous1ccd57c2017-03-21 13:15:58 -0700251# security flags
James Feist41d1d182019-10-18 13:57:16 -0700252set (
253 SECURITY_FLAGS
254 "-fstack-protector-strong \
Ed Tanous580f3722018-03-13 16:59:02 -0700255 -fPIE \
256 -fPIC \
257 -D_FORTIFY_SOURCE=2 \
258 -Wformat \
James Feist41d1d182019-10-18 13:57:16 -0700259 -Wformat-security"
Ed Tanousf0d73c22018-07-26 14:24:20 -0700260)
James Feist41d1d182019-10-18 13:57:16 -0700261set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${SECURITY_FLAGS}")
262set (CMAKE_CXX_FLAGS_RELWITHDEBINFO
263 "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${SECURITY_FLAGS}")
Ed Tanous1e439872018-05-18 11:48:52 -0700264set (CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} ${SECURITY_FLAGS}")
Ed Tanous3dac7492017-08-02 13:46:20 -0700265
Ed Tanous580f3722018-03-13 16:59:02 -0700266# Enable link time optimization This is a temporary workaround because
267# INTERPROCEDURAL_OPTIMIZATION isn't available until cmake 3.9. gcc-ar and gcc-
268# ranlib are wrappers around ar and ranlib which add the lto plugin to the
269# command line.
Ed Tanous1e439872018-05-18 11:48:52 -0700270if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
271 if (NOT CMAKE_BUILD_TYPE MATCHES Debug)
272 string (REGEX REPLACE "ar$" "gcc-ar" CMAKE_AR ${CMAKE_AR})
James Feist41d1d182019-10-18 13:57:16 -0700273 string (REGEX
274 REPLACE "ranlib$" "gcc-ranlib" CMAKE_RANLIB ${CMAKE_RANLIB})
Ed Tanous1e439872018-05-18 11:48:52 -0700275 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto -fno-fat-lto-objects")
Borawski.Lukasz109799e2018-01-30 15:04:42 +0100276
Ed Tanous1e439872018-05-18 11:48:52 -0700277 # Reduce the binary size by removing unnecessary dynamic symbol table
278 # entries
James Feist41d1d182019-10-18 13:57:16 -0700279 set (
280 CMAKE_CXX_FLAGS
281 "${CMAKE_CXX_FLAGS} \
Ed Tanous580f3722018-03-13 16:59:02 -0700282 -fvisibility=hidden \
283 -fvisibility-inlines-hidden \
James Feist41d1d182019-10-18 13:57:16 -0700284 -Wl,--exclude-libs,ALL"
285 )
Ed Tanous1e439872018-05-18 11:48:52 -0700286 endif (NOT CMAKE_BUILD_TYPE MATCHES Debug)
287endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
Borawski.Lukasz109799e2018-01-30 15:04:42 +0100288
Ed Tanous1e439872018-05-18 11:48:52 -0700289if (NOT ${YOCTO_DEPENDENCIES}) # Download and unpack googletest at configure
290 # time
291 configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt)
James Feist41d1d182019-10-18 13:57:16 -0700292 execute_process (COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
293 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
294 execute_process (COMMAND ${CMAKE_COMMAND} --build .
295 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
Ed tanous7d95f5f2018-03-23 00:19:20 -0700296
Ed Tanous1e439872018-05-18 11:48:52 -0700297 set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH})
298endif ()
Ed tanous7d95f5f2018-03-23 00:19:20 -0700299
Manojkiran Edac6bfcfc2020-06-14 10:44:11 +0530300find_package (Boost 1.73 REQUIRED)
301message (BOOST_VERSION = ${Boost_VERSION})
Ed Tanous271584a2019-07-09 16:24:22 -0700302include_directories (SYSTEM ${BOOST_SRC_DIR})
303
Ed Tanous580f3722018-03-13 16:59:02 -0700304# add_definitions(-DBOOST_ASIO_ENABLE_HANDLER_TRACKING)
Ed Tanousd4d77e32020-08-18 00:07:28 -0700305add_definitions (-DBOOST_ASIO_USE_TS_EXECUTOR_AS_DEFAULT)
Ed Tanousd3a38062018-07-27 12:06:29 -0700306add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
Ed Tanous39e77502019-03-04 17:35:53 -0800307add_definitions (-DBOOST_BEAST_USE_STD_STRING_VIEW)
Ed Tanous1e439872018-05-18 11:48:52 -0700308add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY)
309add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED)
Manojkiran Edac6bfcfc2020-06-14 10:44:11 +0530310add_definitions (-DBOOST_ASIO_NO_DEPRECATED)
Ed Tanous1e439872018-05-18 11:48:52 -0700311add_definitions (-DBOOST_ALL_NO_LIB)
312add_definitions (-DBOOST_NO_RTTI)
313add_definitions (-DBOOST_NO_TYPEID)
Ed Tanousc85eb8b2018-10-16 14:59:20 -0700314add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING)
James Feist5a7e8772020-07-22 09:08:38 -0700315add_definitions (-DBOOST_URL_STANDALONE)
316add_definitions (-DBOOST_URL_HEADER_ONLY)
Ed tanous7d95f5f2018-03-23 00:19:20 -0700317
Ed Tanousaa2e59c2018-04-12 12:17:20 -0700318# sdbusplus
Ed Tanous1e439872018-05-18 11:48:52 -0700319if (NOT ${YOCTO_DEPENDENCIES})
Ed Tanous271584a2019-07-09 16:24:22 -0700320 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src)
Patrick Williams3d833802020-06-01 07:14:39 -0500321 link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/build)
Ed Tanous1e439872018-05-18 11:48:52 -0700322endif ()
Ed Tanous0fdddb12017-02-28 11:06:34 -0800323
manojkiraneda4eaf2ee2019-12-13 17:10:41 +0530324# Its an Out of tree build,enabling ibm management console for
325# unit-test purpose.
326if (NOT ${YOCTO_DEPENDENCIES})
327 add_definitions(-DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE)
328endif(NOT ${YOCTO_DEPENDENCIES})
329
Ed Tanous580f3722018-03-13 16:59:02 -0700330# Openssl
Ed Tanous1e439872018-05-18 11:48:52 -0700331find_package (OpenSSL REQUIRED)
Ed Tanous271584a2019-07-09 16:24:22 -0700332include_directories (SYSTEM ${OPENSSL_INCLUDE_DIR})
Ed Tanous1e439872018-05-18 11:48:52 -0700333message ("OPENSSL_INCLUDE_DIR ${OPENSSL_INCLUDE_DIR}")
Ed Tanous0fdddb12017-02-28 11:06:34 -0800334
Ed Tanous55c7b7a2018-05-22 15:27:24 -0700335# bmcweb
Ed Tanous1e439872018-05-18 11:48:52 -0700336message ("CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
337if (CMAKE_BUILD_TYPE MATCHES Debug)
James Feistfaf1f432020-07-09 09:51:14 -0700338 message ("Logging enabled")
Ed Tanous55c7b7a2018-05-22 15:27:24 -0700339 add_definitions (-DBMCWEB_ENABLE_LOGGING)
340 add_definitions (-DBMCWEB_ENABLE_DEBUG)
Ed Tanous1e439872018-05-18 11:48:52 -0700341endif (CMAKE_BUILD_TYPE MATCHES Debug)
Ed Tanousaa2e59c2018-04-12 12:17:20 -0700342
Andrew Geissler1f2fbf22018-07-17 07:57:30 -0700343if (NOT "${BMCWEB_INSECURE_DISABLE_SSL}")
Ed Tanousa434f2b2018-07-27 13:04:22 -0700344 add_definitions (-DBMCWEB_ENABLE_SSL)
Andrew Geissler1f2fbf22018-07-17 07:57:30 -0700345endif (NOT "${BMCWEB_INSECURE_DISABLE_SSL}")
Ed Tanousc94ad492019-10-10 15:39:33 -0700346include_directories (${CMAKE_CURRENT_SOURCE_DIR}/http)
Ed Tanous0fdddb12017-02-28 11:06:34 -0800347
Ed Tanous580f3722018-03-13 16:59:02 -0700348# Zlib
Ed Tanous1e439872018-05-18 11:48:52 -0700349find_package (ZLIB REQUIRED)
Ed Tanous271584a2019-07-09 16:24:22 -0700350include_directories (SYSTEM ${ZLIB_INCLUDE_DIRS})
Ed Tanousf9273472017-02-28 16:05:13 -0800351
Ed Tanous4758d5b2017-06-06 15:28:13 -0700352# PAM
Ed Tanous1e439872018-05-18 11:48:52 -0700353option (WEBSERVER_ENABLE_PAM "enable pam authentication" ON)
354if ("${WEBSERVER_ENABLE_PAM}")
355 find_package (PAM REQUIRED)
356else ()
357 add_definitions ("-DWEBSERVER_DISABLE_PAM")
358endif ()
Ed Tanous911ac312017-08-15 09:37:42 -0700359
Ed Tanousf0d73c22018-07-26 14:24:20 -0700360add_definitions ("-Wno-attributes")
Jennifer Lee03346702018-05-23 14:05:20 -0700361# Copy pam-webserver to etc/pam.d
James Feist41d1d182019-10-18 13:57:16 -0700362install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/pam-webserver DESTINATION /etc/pam.d/
363 RENAME webserver)
Ed Tanous5f34a9c2017-02-28 12:35:13 -0800364
Ed tanous7d95f5f2018-03-23 00:19:20 -0700365# tinyxml2
Ed Tanous1e439872018-05-18 11:48:52 -0700366find_package (tinyxml2 REQUIRED)
Ed tanous7d95f5f2018-03-23 00:19:20 -0700367
Ed Tanous1e439872018-05-18 11:48:52 -0700368set (WEBSERVER_MAIN src/webserver_main.cpp)
Ed Tanousb4d29f42017-03-24 16:39:25 -0700369
Ed Tanous1e439872018-05-18 11:48:52 -0700370include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
371include_directories (${CMAKE_CURRENT_SOURCE_DIR}/redfish-core/include)
Przemyslaw Czarnowskie13c2762019-09-02 17:32:43 +0200372include_directories (${CMAKE_CURRENT_SOURCE_DIR}/redfish-core/lib)
Ed Tanousb4d29f42017-03-24 16:39:25 -0700373
Ed Tanous1e439872018-05-18 11:48:52 -0700374file (MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/include/bmcweb)
Ed Tanous1e439872018-05-18 11:48:52 -0700375include_directories (${CMAKE_BINARY_DIR}/include)
Ed Tanous5f34a9c2017-02-28 12:35:13 -0800376
James Feist41d1d182019-10-18 13:57:16 -0700377set (SRC_FILES redfish-core/src/error_messages.cpp
378 redfish-core/src/utils/json_utils.cpp ${GENERATED_SRC_FILES})
Ed Tanous93f987d2017-04-17 17:52:36 -0700379
Ed Tanous1e439872018-05-18 11:48:52 -0700380file (COPY src/test_resources DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
Ed Tanous911ac312017-08-15 09:37:42 -0700381
Ed Tanous38bdb982017-03-03 14:19:33 -0800382# Unit Tests
manojkiraneda4eaf2ee2019-12-13 17:10:41 +0530383if (NOT ${YOCTO_DEPENDENCIES})
384 set (UT_FILES src/gtest_main.cpp src/msan_test.cpp
James Feist41d1d182019-10-18 13:57:16 -0700385 redfish-core/ut/privileges_test.cpp
manojkiraneda4eaf2ee2019-12-13 17:10:41 +0530386 redfish-core/ut/lock_test.cpp
Jonathan Doman5beaf842020-08-14 11:23:33 -0700387 http/ut/utility_test.cpp
James Feist41d1d182019-10-18 13:57:16 -0700388 ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp) # big list of naughty
389 # strings
390 add_custom_command (OUTPUT ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp
391 COMMAND
392 xxd -i
393 ${CMAKE_CURRENT_SOURCE_DIR}/src/test_resources/blns
394 ${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp)
Ed Tanous1e439872018-05-18 11:48:52 -0700395
James Feist41d1d182019-10-18 13:57:16 -0700396 set_source_files_properties (${CMAKE_BINARY_DIR}/include/bmcweb/blns.hpp
397 PROPERTIES GENERATED TRUE)
Ed Tanous1e439872018-05-18 11:48:52 -0700398 enable_testing ()
399
400 add_executable (webtest ${SRC_FILES} ${UT_FILES})
401
402 find_package (GTest REQUIRED)
403 find_package (GMock REQUIRED)
404 target_link_libraries (webtest ${GTEST_LIBRARIES})
405 target_link_libraries (webtest ${GMOCK_LIBRARIES})
406
407 target_link_libraries (webtest pthread)
408 target_link_libraries (webtest ${OPENSSL_LIBRARIES})
409 target_link_libraries (webtest ${ZLIB_LIBRARIES})
410 target_link_libraries (webtest pam)
411 target_link_libraries (webtest tinyxml2)
Ed Tanousd425c6f2018-05-16 10:20:11 -0700412 target_link_libraries (webtest sdbusplus)
Ed Tanouse0625902018-05-16 13:35:08 -0700413 target_link_libraries (webtest -lsystemd)
Ed Tanous1e439872018-05-18 11:48:52 -0700414 target_link_libraries (webtest -lstdc++fs)
415 add_test (webtest webtest "--gtest_output=xml:webtest.xml")
416
manojkiraneda4eaf2ee2019-12-13 17:10:41 +0530417endif (NOT ${YOCTO_DEPENDENCIES})
Ed Tanous1e439872018-05-18 11:48:52 -0700418
419install (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/static/ DESTINATION share/www)
420
421# bmcweb
422add_executable (bmcweb ${WEBSERVER_MAIN} ${HDR_FILES} ${SRC_FILES})
Ed Tanous1e439872018-05-18 11:48:52 -0700423target_link_libraries (bmcweb ${OPENSSL_LIBRARIES})
424target_link_libraries (bmcweb ${ZLIB_LIBRARIES})
425target_link_libraries (bmcweb pam)
Brad Bishop79ba46f2018-11-29 10:57:31 -0500426target_link_libraries (bmcweb -latomic)
Ed Tanous1e439872018-05-18 11:48:52 -0700427target_link_libraries (bmcweb -lsystemd)
428target_link_libraries (bmcweb -lstdc++fs)
Ed Tanousd425c6f2018-05-16 10:20:11 -0700429target_link_libraries (bmcweb sdbusplus)
Ed Tanous1e439872018-05-18 11:48:52 -0700430target_link_libraries (bmcweb tinyxml2)
431install (TARGETS bmcweb DESTINATION bin)
432
Jason M. Billsc50fc5a2018-11-14 14:49:59 -0800433target_compile_definitions (
James Feist41d1d182019-10-18 13:57:16 -0700434 bmcweb PRIVATE $<$<BOOL:${BMCWEB_ENABLE_KVM}>: -DBMCWEB_ENABLE_KVM>
Kowalski, Kamil55e43f62019-07-10 13:12:57 +0200435 $<$<BOOL:${BMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION}>: -DBMCWEB_ENABLE_MUTUAL_TLS_AUTHENTICATION>
Adriana Kobylak1bfbe0e2019-01-17 12:08:38 -0600436 $<$<BOOL:${BMCWEB_ENABLE_VM_WEBSOCKET}>: -DBMCWEB_ENABLE_VM_WEBSOCKET>
Iwona Klimaszewskac0a1c8a2019-07-12 18:26:38 +0200437 $<$<BOOL:${BMCWEB_ENABLE_VM_NBDPROXY}>: -DBMCWEB_ENABLE_VM_NBDPROXY>
Jason M. Billsc50fc5a2018-11-14 14:49:59 -0800438 $<$<BOOL:${BMCWEB_ENABLE_DBUS_REST}>: -DBMCWEB_ENABLE_DBUS_REST>
439 $<$<BOOL:${BMCWEB_ENABLE_REDFISH}>: -DBMCWEB_ENABLE_REDFISH>
440 $<$<BOOL:${BMCWEB_ENABLE_STATIC_HOSTING}>: -DBMCWEB_ENABLE_STATIC_HOSTING>
James Feist41d1d182019-10-18 13:57:16 -0700441 $<$<BOOL:${BMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET}>:
442 -DBMCWEB_ENABLE_HOST_SERIAL_WEBSOCKET>
443 $<$<BOOL:${BMCWEB_INSECURE_DISABLE_CSRF_PREVENTION}>:
444 -DBMCWEB_INSECURE_DISABLE_CSRF_PREVENTION>
Jason M. Billsc50fc5a2018-11-14 14:49:59 -0800445 $<$<BOOL:${BMCWEB_INSECURE_DISABLE_SSL}>: -DBMCWEB_INSECURE_DISABLE_SSL>
James Feist41d1d182019-10-18 13:57:16 -0700446 $<$<BOOL:${BMCWEB_INSECURE_DISABLE_XSS_PREVENTION}>:
447 -DBMCWEB_INSECURE_DISABLE_XSS_PREVENTION>
448 $<$<BOOL:${BMCWEB_ENABLE_REDFISH_RAW_PECI}>:
449 -DBMCWEB_ENABLE_REDFISH_RAW_PECI>
450 $<$<BOOL:${BMCWEB_ENABLE_REDFISH_CPU_LOG}>:
451 -DBMCWEB_ENABLE_REDFISH_CPU_LOG>
Asmitha Karunanithi5cb1dd22020-05-07 04:35:02 -0500452 $<$<BOOL:${BMCWEB_ENABLE_REDFISH_DUMP_LOG}>:
453 -DBMCWEB_ENABLE_REDFISH_DUMP_LOG>
James Feist41d1d182019-10-18 13:57:16 -0700454 $<$<BOOL:${BMCWEB_ENABLE_REDFISH_BMC_JOURNAL}>:
455 -DBMCWEB_ENABLE_REDFISH_BMC_JOURNAL>
456 $<$<BOOL:${BMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES}>:
457 -DBMCWEB_ENABLE_REDFISH_DBUS_LOG_ENTRIES>
458 $<$<BOOL:${BMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE}>:
459 -DBMCWEB_INSECURE_ENABLE_REDFISH_FW_TFTP_UPDATE>
AppaRao Pulia6349912019-10-18 17:16:08 +0530460 $<$<BOOL:${BMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE}>:
461 -DBMCWEB_ENABLE_REDFISH_PROVISIONING_FEATURE>
jayaprakash Mutyala70d1d0a2020-01-21 23:41:36 +0000462 $<$<BOOL:${BMCWEB_ENABLE_VALIDATION_UNSECURE_FEATURE}>:
463 -DBMCWEB_ENABLE_VALIDATION_UNSECURE_FEATURE>
jayaprakash Mutyala91e130a2020-03-04 22:26:38 +0000464 $<$<BOOL:${BMCWEB_INSECURE_UNRESTRICTED_SENSOR_OVERRIDE}>:
465 -DBMCWEB_INSECURE_UNRESTRICTED_SENSOR_OVERRIDE>
Ratan Gupta453fed02019-12-14 09:39:47 +0530466 $<$<BOOL:${BMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE}>:
467 -DBMCWEB_ENABLE_IBM_MANAGEMENT_CONSOLE>
AppaRao Pulib52664e2020-04-09 21:36:51 +0530468 $<$<BOOL:${BMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING}>:
469 -DBMCWEB_INSECURE_ENABLE_HTTP_PUSH_STYLE_EVENTING>
Brad Bishopf5e906b2018-11-29 10:55:10 -0500470)
Brad Bishop5a7094b2019-04-10 19:33:15 -0400471
472# configure and install systemd unit files
473configure_file (bmcweb.socket bmcweb.socket COPYONLY)
474configure_file (bmcweb.service.in bmcweb.service)
475pkg_get_variable (SYSTEMD_SYSTEMUNITDIR systemd systemdsystemunitdir)
James Feist41d1d182019-10-18 13:57:16 -0700476install (FILES ${PROJECT_BINARY_DIR}/bmcweb.socket DESTINATION
477 ${SYSTEMD_SYSTEMUNITDIR})
478install (FILES ${PROJECT_BINARY_DIR}/bmcweb.service DESTINATION
479 ${SYSTEMD_SYSTEMUNITDIR})