Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 3.6) |
| 2 | project (host-error-monitor CXX) |
Jason M. Bills | 3c546f9 | 2020-05-18 09:24:48 -0700 | [diff] [blame] | 3 | include (ExternalProject) |
Jason M. Bills | 36f8724 | 2022-09-21 15:48:01 -0700 | [diff] [blame] | 4 | set (CMAKE_CXX_STANDARD 20) |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 5 | set (CMAKE_CXX_STANDARD_REQUIRED ON) |
| 6 | |
| 7 | add_executable (host-error-monitor src/host_error_monitor.cpp) |
| 8 | |
Jason M. Bills | 9478544 | 2020-01-07 15:22:09 -0800 | [diff] [blame] | 9 | option (HOST_ERROR_CRASHDUMP_ON_SMI_TIMEOUT "Enable crashdump on SMI Timeout." |
| 10 | OFF) |
| 11 | |
Jason M. Bills | 3c546f9 | 2020-05-18 09:24:48 -0700 | [diff] [blame] | 12 | option (YOCTO "Enable Building in Yocto" OFF) |
Zev Weiss | 03ed41b | 2023-04-10 20:03:08 -0700 | [diff] [blame] | 13 | option (LIBPECI "Enable use of old peci driver API via libpeci" OFF) |
Zev Weiss | 08d16db | 2023-05-16 16:54:43 -0700 | [diff] [blame] | 14 | option (CRASHDUMP "Enable use of the Intel Crashdump service" OFF) |
Jason M. Bills | 3c546f9 | 2020-05-18 09:24:48 -0700 | [diff] [blame] | 15 | |
Zev Weiss | 03ed41b | 2023-04-10 20:03:08 -0700 | [diff] [blame] | 16 | if (LIBPECI AND NOT YOCTO) |
Jason M. Bills | 3c546f9 | 2020-05-18 09:24:48 -0700 | [diff] [blame] | 17 | 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) |
| 31 | endif () |
| 32 | |
Jason M. Bills | 9478544 | 2020-01-07 15:22:09 -0800 | [diff] [blame] | 33 | target_compile_definitions (host-error-monitor PRIVATE |
| 34 | $<$<BOOL:${HOST_ERROR_CRASHDUMP_ON_SMI_TIMEOUT}>: |
| 35 | -DHOST_ERROR_CRASHDUMP_ON_SMI_TIMEOUT>) |
| 36 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 37 | target_include_directories (host-error-monitor PRIVATE ${CMAKE_SOURCE_DIR}) |
| 38 | |
Zev Weiss | 03ed41b | 2023-04-10 20:03:08 -0700 | [diff] [blame] | 39 | target_link_libraries (host-error-monitor sdbusplus -lsystemd gpiodcxx) |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 40 | |
| 41 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 42 | |
| 43 | install (TARGETS host-error-monitor |
| 44 | RUNTIME DESTINATION bin |
| 45 | LIBRARY DESTINATION lib |
| 46 | ARCHIVE DESTINATION lib/static) |
| 47 | |
| 48 | find_package (Boost 1.66 REQUIRED) |
| 49 | include_directories (${BOOST_SRC_DIR}) |
| 50 | |
| 51 | add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) |
| 52 | add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) |
| 53 | add_definitions (-DBOOST_ALL_NO_LIB) |
| 54 | add_definitions (-DBOOST_NO_RTTI) |
| 55 | add_definitions (-DBOOST_NO_TYPEID) |
| 56 | add_definitions (-DBOOST_ASIO_DISABLE_THREADS) |
| 57 | |
Zev Weiss | 03ed41b | 2023-04-10 20:03:08 -0700 | [diff] [blame] | 58 | if (LIBPECI) |
| 59 | add_definitions (-DLIBPECI) |
| 60 | target_link_libraries (host-error-monitor peci) |
| 61 | endif () |
| 62 | |
Zev Weiss | 08d16db | 2023-05-16 16:54:43 -0700 | [diff] [blame] | 63 | if (CRASHDUMP) |
| 64 | add_definitions (-DCRASHDUMP) |
| 65 | endif () |
| 66 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 67 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") |
| 68 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti") |
| 69 | |
Jason M. Bills | 92608b3 | 2023-06-27 14:22:58 -0700 | [diff] [blame] | 70 | find_package (PkgConfig REQUIRED) |
| 71 | pkg_get_variable(SYSTEMD_SYSTEM_UNIT_DIR systemd systemdsystemunitdir) |
| 72 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 73 | set ( |
| 74 | SERVICE_FILES |
| 75 | ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.HostErrorMonitor.service |
| 76 | ) |
Jason M. Bills | 92608b3 | 2023-06-27 14:22:58 -0700 | [diff] [blame] | 77 | install (FILES ${SERVICE_FILES} DESTINATION "${SYSTEMD_SYSTEM_UNIT_DIR}") |