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) |
Jason M. Bills | 3c546f9 | 2020-05-18 09:24:48 -0700 | [diff] [blame] | 14 | |
Zev Weiss | 03ed41b | 2023-04-10 20:03:08 -0700 | [diff] [blame^] | 15 | if (LIBPECI AND NOT YOCTO) |
Jason M. Bills | 3c546f9 | 2020-05-18 09:24:48 -0700 | [diff] [blame] | 16 | add_dependencies (host-error-monitor libpeci) |
| 17 | externalproject_add (libpeci PREFIX ${CMAKE_BINARY_DIR}/libpeci |
| 18 | GIT_REPOSITORY https://github.com/openbmc/libpeci.git |
| 19 | GIT_TAG a2ceec2aa139277cebb62e1eda449ef60fa4c962 |
| 20 | INSTALL_COMMAND "") |
| 21 | |
| 22 | externalproject_get_property (libpeci SOURCE_DIR) |
| 23 | include_directories (${SOURCE_DIR}) |
| 24 | |
| 25 | externalproject_get_property (libpeci BINARY_DIR) |
| 26 | add_library (peci SHARED IMPORTED) |
| 27 | set_target_properties (peci |
| 28 | PROPERTIES IMPORTED_LOCATION |
| 29 | ${BINARY_DIR}/libpeci.so) |
| 30 | endif () |
| 31 | |
Jason M. Bills | 9478544 | 2020-01-07 15:22:09 -0800 | [diff] [blame] | 32 | target_compile_definitions (host-error-monitor PRIVATE |
| 33 | $<$<BOOL:${HOST_ERROR_CRASHDUMP_ON_SMI_TIMEOUT}>: |
| 34 | -DHOST_ERROR_CRASHDUMP_ON_SMI_TIMEOUT>) |
| 35 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 36 | target_include_directories (host-error-monitor PRIVATE ${CMAKE_SOURCE_DIR}) |
| 37 | |
Zev Weiss | 03ed41b | 2023-04-10 20:03:08 -0700 | [diff] [blame^] | 38 | target_link_libraries (host-error-monitor sdbusplus -lsystemd gpiodcxx) |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 39 | |
| 40 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 41 | |
| 42 | install (TARGETS host-error-monitor |
| 43 | RUNTIME DESTINATION bin |
| 44 | LIBRARY DESTINATION lib |
| 45 | ARCHIVE DESTINATION lib/static) |
| 46 | |
| 47 | find_package (Boost 1.66 REQUIRED) |
| 48 | include_directories (${BOOST_SRC_DIR}) |
| 49 | |
| 50 | add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) |
| 51 | add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) |
| 52 | add_definitions (-DBOOST_ALL_NO_LIB) |
| 53 | add_definitions (-DBOOST_NO_RTTI) |
| 54 | add_definitions (-DBOOST_NO_TYPEID) |
| 55 | add_definitions (-DBOOST_ASIO_DISABLE_THREADS) |
| 56 | |
Zev Weiss | 03ed41b | 2023-04-10 20:03:08 -0700 | [diff] [blame^] | 57 | if (LIBPECI) |
| 58 | add_definitions (-DLIBPECI) |
| 59 | target_link_libraries (host-error-monitor peci) |
| 60 | endif () |
| 61 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 62 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") |
| 63 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti") |
| 64 | |
| 65 | set ( |
| 66 | SERVICE_FILES |
| 67 | ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.HostErrorMonitor.service |
| 68 | ) |
| 69 | install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) |