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 | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 4 | set (CMAKE_CXX_STANDARD 17) |
| 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) |
| 13 | |
| 14 | if (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) |
| 29 | endif () |
| 30 | |
Jason M. Bills | 9478544 | 2020-01-07 15:22:09 -0800 | [diff] [blame] | 31 | target_compile_definitions (host-error-monitor PRIVATE |
| 32 | $<$<BOOL:${HOST_ERROR_CRASHDUMP_ON_SMI_TIMEOUT}>: |
| 33 | -DHOST_ERROR_CRASHDUMP_ON_SMI_TIMEOUT>) |
| 34 | |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 35 | target_include_directories (host-error-monitor PRIVATE ${CMAKE_SOURCE_DIR}) |
| 36 | |
Jason M. Bills | 6a2cb69 | 2019-08-06 11:03:49 -0700 | [diff] [blame] | 37 | target_link_libraries (host-error-monitor sdbusplus -lsystemd gpiodcxx peci) |
Jason M. Bills | 1490b14 | 2019-07-01 15:48:43 -0700 | [diff] [blame] | 38 | |
| 39 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 40 | |
| 41 | install (TARGETS host-error-monitor |
| 42 | RUNTIME DESTINATION bin |
| 43 | LIBRARY DESTINATION lib |
| 44 | ARCHIVE DESTINATION lib/static) |
| 45 | |
| 46 | find_package (Boost 1.66 REQUIRED) |
| 47 | include_directories (${BOOST_SRC_DIR}) |
| 48 | |
| 49 | add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) |
| 50 | add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) |
| 51 | add_definitions (-DBOOST_ALL_NO_LIB) |
| 52 | add_definitions (-DBOOST_NO_RTTI) |
| 53 | add_definitions (-DBOOST_NO_TYPEID) |
| 54 | add_definitions (-DBOOST_ASIO_DISABLE_THREADS) |
| 55 | |
| 56 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") |
| 57 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti") |
| 58 | |
| 59 | set ( |
| 60 | SERVICE_FILES |
| 61 | ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.HostErrorMonitor.service |
| 62 | ) |
| 63 | install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) |