Kuiying Wang | 3a04440 | 2019-02-19 15:00:11 +0800 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR) |
| 2 | project(post-code-manager CXX) |
Alan Kuo | 0171dd6 | 2021-04-15 10:47:32 +0800 | [diff] [blame] | 3 | option ( |
| 4 | ENABLE_BIOS_POST_CODE_LOG |
| 5 | "Enable Bios Post Code Logging" |
| 6 | OFF |
| 7 | ) |
Kuiying Wang | 3a04440 | 2019-02-19 15:00:11 +0800 | [diff] [blame] | 8 | set(CMAKE_CXX_STANDARD 17) |
| 9 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 10 | |
| 11 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) |
| 12 | include(GNUInstallDirs) |
| 13 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) |
| 14 | include_directories(${CMAKE_CURRENT_BINARY_DIR}) |
| 15 | |
Jonathan Doman | 08125ca | 2021-01-07 17:49:15 -0800 | [diff] [blame] | 16 | set(DBUS_OBJECT_NAME "xyz/openbmc_project/State/Boot/PostCode0") |
Kuiying Wang | 3a04440 | 2019-02-19 15:00:11 +0800 | [diff] [blame] | 17 | set(DBUS_INTF_NAME "xyz.openbmc_project.State.Boot.PostCode") |
Manojkiran Eda | aed7b3d | 2021-06-19 09:39:30 +0530 | [diff] [blame] | 18 | set(MAX_BOOT_CYCLE_COUNT 100 CACHE STRING "Max boot count Value") |
| 19 | if(NOT MAX_BOOT_CYCLE_COUNT MATCHES "^([1-9][0-9]?|100)$") |
| 20 | message(FATAL_ERROR "Maximum boot cycle count must be a number from 1 to 100") |
| 21 | endif() |
Kuiying Wang | 3a04440 | 2019-02-19 15:00:11 +0800 | [diff] [blame] | 22 | |
| 23 | add_definitions(-DDBUS_OBJECT_NAME="/${DBUS_OBJECT_NAME}") |
| 24 | add_definitions(-DDBUS_INTF_NAME="${DBUS_INTF_NAME}") |
Manojkiran Eda | aed7b3d | 2021-06-19 09:39:30 +0530 | [diff] [blame] | 25 | add_definitions(-DMAX_BOOT_CYCLE_COUNT=${MAX_BOOT_CYCLE_COUNT}) |
| 26 | |
Kuiying Wang | 3a04440 | 2019-02-19 15:00:11 +0800 | [diff] [blame] | 27 | set(SRC_FILES src/post_code.cpp |
| 28 | src/main.cpp ) |
| 29 | set ( SERVICE_FILES |
Kumar Thangavel | fd45f78 | 2020-09-01 22:59:00 +0530 | [diff] [blame] | 30 | service_files/xyz.openbmc_project.State.Boot.PostCode.service |
| 31 | service_files/xyz.openbmc_project.State.Boot.PostCode@.service ) |
Kuiying Wang | 3a04440 | 2019-02-19 15:00:11 +0800 | [diff] [blame] | 32 | |
| 33 | # import sdbusplus |
| 34 | find_package(PkgConfig REQUIRED) |
| 35 | pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED) |
| 36 | include_directories(${SDBUSPLUSPLUS_INCLUDE_DIRS}) |
| 37 | link_directories(${SDBUSPLUSPLUS_LIBRARY_DIRS}) |
| 38 | find_program(SDBUSPLUSPLUS sdbus++) |
| 39 | |
| 40 | # import phosphor-logging |
| 41 | find_package(PkgConfig REQUIRED) |
| 42 | pkg_check_modules(LOGGING phosphor-logging REQUIRED) |
| 43 | include_directories(${LOGGING_INCLUDE_DIRS}) |
| 44 | link_directories(${LOGGING_LIBRARY_DIRS}) |
| 45 | |
| 46 | # phosphor-dbus-interfaces |
| 47 | find_package(PkgConfig REQUIRED) |
| 48 | pkg_check_modules(DBUSINTERFACE phosphor-dbus-interfaces REQUIRED) |
| 49 | include_directories(${DBUSINTERFACE_INCLUDE_DIRS}) |
| 50 | link_directories(${DBUSINTERFACE_LIBRARY_DIRS}) |
| 51 | |
| 52 | add_executable(${PROJECT_NAME} ${SRC_FILES}) |
| 53 | target_link_libraries(${PROJECT_NAME} ${DBUSINTERFACE_LIBRARIES} ) |
Manojkiran Eda | 410ba29 | 2021-12-05 10:55:56 +0530 | [diff] [blame] | 54 | target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus") |
Kuiying Wang | 3a04440 | 2019-02-19 15:00:11 +0800 | [diff] [blame] | 55 | |
| 56 | install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) |
Alan Kuo | 0171dd6 | 2021-04-15 10:47:32 +0800 | [diff] [blame] | 57 | target_compile_definitions ( |
| 58 | ${PROJECT_NAME} PRIVATE $<$<BOOL:${ENABLE_BIOS_POST_CODE_LOG}>: -DENABLE_BIOS_POST_CODE_LOG> |
| 59 | ) |
Kumar Thangavel | fd45f78 | 2020-09-01 22:59:00 +0530 | [diff] [blame] | 60 | install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) |