blob: fa153bc75d384cca67a0a953ca68e3c7693a7bae [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)
Zev Weiss03ed41b2023-04-10 20:03:08 -070013option (LIBPECI "Enable use of old peci driver API via libpeci" OFF)
Zev Weiss08d16db2023-05-16 16:54:43 -070014option (CRASHDUMP "Enable use of the Intel Crashdump service" OFF)
Jason M. Bills3c546f92020-05-18 09:24:48 -070015
Zev Weiss03ed41b2023-04-10 20:03:08 -070016if (LIBPECI AND NOT YOCTO)
Jason M. Bills3c546f92020-05-18 09:24:48 -070017 add_dependencies (host-error-monitor libpeci)
18 externalproject_add (libpeci PREFIX ${CMAKE_BINARY_DIR}/libpeci
19 GIT_REPOSITORY https://github.com/openbmc/libpeci.git
20 GIT_TAG a2ceec2aa139277cebb62e1eda449ef60fa4c962
21 INSTALL_COMMAND "")
22
23 externalproject_get_property (libpeci SOURCE_DIR)
24 include_directories (${SOURCE_DIR})
25
26 externalproject_get_property (libpeci BINARY_DIR)
27 add_library (peci SHARED IMPORTED)
28 set_target_properties (peci
29 PROPERTIES IMPORTED_LOCATION
30 ${BINARY_DIR}/libpeci.so)
31endif ()
32
Jason M. Bills94785442020-01-07 15:22:09 -080033target_compile_definitions (host-error-monitor PRIVATE
34 $<$<BOOL:${HOST_ERROR_CRASHDUMP_ON_SMI_TIMEOUT}>:
35 -DHOST_ERROR_CRASHDUMP_ON_SMI_TIMEOUT>)
36
Jason M. Bills1490b142019-07-01 15:48:43 -070037target_include_directories (host-error-monitor PRIVATE ${CMAKE_SOURCE_DIR})
38
Zev Weiss03ed41b2023-04-10 20:03:08 -070039target_link_libraries (host-error-monitor sdbusplus -lsystemd gpiodcxx)
Jason M. Bills1490b142019-07-01 15:48:43 -070040
41include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
42
43install (TARGETS host-error-monitor
44 RUNTIME DESTINATION bin
45 LIBRARY DESTINATION lib
46 ARCHIVE DESTINATION lib/static)
47
48find_package (Boost 1.66 REQUIRED)
49include_directories (${BOOST_SRC_DIR})
50
51add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY)
52add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED)
53add_definitions (-DBOOST_ALL_NO_LIB)
54add_definitions (-DBOOST_NO_RTTI)
55add_definitions (-DBOOST_NO_TYPEID)
56add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
57
Zev Weiss03ed41b2023-04-10 20:03:08 -070058if (LIBPECI)
59 add_definitions (-DLIBPECI)
60 target_link_libraries (host-error-monitor peci)
61endif ()
62
Zev Weiss08d16db2023-05-16 16:54:43 -070063if (CRASHDUMP)
64 add_definitions (-DCRASHDUMP)
65endif ()
66
Jason M. Bills1490b142019-07-01 15:48:43 -070067set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
68set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti")
69
Jason M. Bills92608b32023-06-27 14:22:58 -070070find_package (PkgConfig REQUIRED)
71pkg_get_variable(SYSTEMD_SYSTEM_UNIT_DIR systemd systemdsystemunitdir)
72
Jason M. Bills1490b142019-07-01 15:48:43 -070073set (
74 SERVICE_FILES
75 ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.HostErrorMonitor.service
76)
Jason M. Bills92608b32023-06-27 14:22:58 -070077install (FILES ${SERVICE_FILES} DESTINATION "${SYSTEMD_SYSTEM_UNIT_DIR}")