blob: b8457ceb920cf846afe33e2dca766e31b2e5c7e3 [file] [log] [blame]
Jason M. Bills1490b142019-07-01 15:48:43 -07001cmake_minimum_required (VERSION 3.6)
2project (host-error-monitor CXX)
Jason M. Bills3c546f92020-05-18 09:24:48 -07003include (ExternalProject)
Jason M. Bills36f87242022-09-21 15:48:01 -07004set (CMAKE_CXX_STANDARD 20)
Jason M. Bills1490b142019-07-01 15:48:43 -07005set (CMAKE_CXX_STANDARD_REQUIRED ON)
6
7add_executable (host-error-monitor src/host_error_monitor.cpp)
8
Jason M. Bills94785442020-01-07 15:22:09 -08009option (HOST_ERROR_CRASHDUMP_ON_SMI_TIMEOUT "Enable crashdump on SMI Timeout."
10 OFF)
11
Jason M. Bills3c546f92020-05-18 09:24:48 -070012option (YOCTO "Enable Building in Yocto" OFF)
13
14if (NOT YOCTO)
15 add_dependencies (host-error-monitor libpeci)
16 externalproject_add (libpeci PREFIX ${CMAKE_BINARY_DIR}/libpeci
17 GIT_REPOSITORY https://github.com/openbmc/libpeci.git
18 GIT_TAG a2ceec2aa139277cebb62e1eda449ef60fa4c962
19 INSTALL_COMMAND "")
20
21 externalproject_get_property (libpeci SOURCE_DIR)
22 include_directories (${SOURCE_DIR})
23
24 externalproject_get_property (libpeci BINARY_DIR)
25 add_library (peci SHARED IMPORTED)
26 set_target_properties (peci
27 PROPERTIES IMPORTED_LOCATION
28 ${BINARY_DIR}/libpeci.so)
29endif ()
30
Jason M. Bills94785442020-01-07 15:22:09 -080031target_compile_definitions (host-error-monitor PRIVATE
32 $<$<BOOL:${HOST_ERROR_CRASHDUMP_ON_SMI_TIMEOUT}>:
33 -DHOST_ERROR_CRASHDUMP_ON_SMI_TIMEOUT>)
34
Jason M. Bills1490b142019-07-01 15:48:43 -070035target_include_directories (host-error-monitor PRIVATE ${CMAKE_SOURCE_DIR})
36
Jason M. Bills6a2cb692019-08-06 11:03:49 -070037target_link_libraries (host-error-monitor sdbusplus -lsystemd gpiodcxx peci)
Jason M. Bills1490b142019-07-01 15:48:43 -070038
39include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
40
41install (TARGETS host-error-monitor
42 RUNTIME DESTINATION bin
43 LIBRARY DESTINATION lib
44 ARCHIVE DESTINATION lib/static)
45
46find_package (Boost 1.66 REQUIRED)
47include_directories (${BOOST_SRC_DIR})
48
49add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY)
50add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED)
51add_definitions (-DBOOST_ALL_NO_LIB)
52add_definitions (-DBOOST_NO_RTTI)
53add_definitions (-DBOOST_NO_TYPEID)
54add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
55
56set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
57set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti")
58
59set (
60 SERVICE_FILES
61 ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.HostErrorMonitor.service
62)
63install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)