blob: 6d291cc53794523e01e13c2574affb261628d12b [file] [log] [blame]
Kuiying Wang3a044402019-02-19 15:00:11 +08001cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
2project(post-code-manager CXX)
Alan Kuo0171dd62021-04-15 10:47:32 +08003option (
4 ENABLE_BIOS_POST_CODE_LOG
5 "Enable Bios Post Code Logging"
6 OFF
7)
Kuiying Wang3a044402019-02-19 15:00:11 +08008set(CMAKE_CXX_STANDARD 17)
9set(CMAKE_CXX_STANDARD_REQUIRED ON)
10
11set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
12include(GNUInstallDirs)
13include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
14include_directories(${CMAKE_CURRENT_BINARY_DIR})
15
Jonathan Doman08125ca2021-01-07 17:49:15 -080016set(DBUS_OBJECT_NAME "xyz/openbmc_project/State/Boot/PostCode0")
Kuiying Wang3a044402019-02-19 15:00:11 +080017set(DBUS_INTF_NAME "xyz.openbmc_project.State.Boot.PostCode")
Manojkiran Edaaed7b3d2021-06-19 09:39:30 +053018set(MAX_BOOT_CYCLE_COUNT 100 CACHE STRING "Max boot count Value")
19if(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")
21endif()
Kuiying Wang3a044402019-02-19 15:00:11 +080022
23add_definitions(-DDBUS_OBJECT_NAME="/${DBUS_OBJECT_NAME}")
24add_definitions(-DDBUS_INTF_NAME="${DBUS_INTF_NAME}")
Manojkiran Edaaed7b3d2021-06-19 09:39:30 +053025add_definitions(-DMAX_BOOT_CYCLE_COUNT=${MAX_BOOT_CYCLE_COUNT})
26
Kuiying Wang3a044402019-02-19 15:00:11 +080027set(SRC_FILES src/post_code.cpp
28 src/main.cpp )
29set ( SERVICE_FILES
Kumar Thangavelfd45f782020-09-01 22:59:00 +053030 service_files/xyz.openbmc_project.State.Boot.PostCode.service
31 service_files/xyz.openbmc_project.State.Boot.PostCode@.service )
Kuiying Wang3a044402019-02-19 15:00:11 +080032
33# import sdbusplus
34find_package(PkgConfig REQUIRED)
35pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED)
36include_directories(${SDBUSPLUSPLUS_INCLUDE_DIRS})
37link_directories(${SDBUSPLUSPLUS_LIBRARY_DIRS})
38find_program(SDBUSPLUSPLUS sdbus++)
39
40# import phosphor-logging
41find_package(PkgConfig REQUIRED)
42pkg_check_modules(LOGGING phosphor-logging REQUIRED)
43include_directories(${LOGGING_INCLUDE_DIRS})
44link_directories(${LOGGING_LIBRARY_DIRS})
45
46# phosphor-dbus-interfaces
47find_package(PkgConfig REQUIRED)
48pkg_check_modules(DBUSINTERFACE phosphor-dbus-interfaces REQUIRED)
49include_directories(${DBUSINTERFACE_INCLUDE_DIRS})
50link_directories(${DBUSINTERFACE_LIBRARY_DIRS})
51
52add_executable(${PROJECT_NAME} ${SRC_FILES})
53target_link_libraries(${PROJECT_NAME} ${DBUSINTERFACE_LIBRARIES} )
54target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lstdc++fs -lphosphor_dbus")
55
56install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
Alan Kuo0171dd62021-04-15 10:47:32 +080057target_compile_definitions (
58 ${PROJECT_NAME} PRIVATE $<$<BOOL:${ENABLE_BIOS_POST_CODE_LOG}>: -DENABLE_BIOS_POST_CODE_LOG>
59)
Kumar Thangavelfd45f782020-09-01 22:59:00 +053060install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)