blob: edcccada1ddc29b3ce274213c3fc640fc318fcc7 [file] [log] [blame]
Kuiying Wang64ff7ce2018-08-15 11:17:06 +08001cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
Jason M. Bills0d57f4e2021-10-21 14:11:41 -07002project(power-control CXX)
Patrick Venture219a2f92018-11-05 16:54:36 -08003set(CMAKE_CXX_STANDARD 17)
Kuiying Wang64ff7ce2018-08-15 11:17:06 +08004set(CMAKE_CXX_STANDARD_REQUIRED ON)
5
Jason M. Bills0d57f4e2021-10-21 14:11:41 -07006option (
7 CHASSIS_SYSTEM_RESET
8 "Enable chassis system power reset to allow removing
9 power and restoring back"
10 OFF
11)
12option (
13 USE_PLT_RST
14 "Use the PLT_RST eSPI signal to detect warm reset
15 instead of POST Complete"
16 OFF
17)
18
19add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
20add_definitions(-DBOOST_SYSTEM_NO_DEPRECATED)
21add_definitions(-DBOOST_ALL_NO_LIB)
22add_definitions(-DBOOST_NO_RTTI)
23add_definitions(-DBOOST_NO_TYPEID)
24add_definitions(-DBOOST_ASIO_DISABLE_THREADS)
25
26set(SRC_FILES src/power_control.cpp)
27
28add_executable(${PROJECT_NAME} ${SRC_FILES})
29target_link_libraries(${PROJECT_NAME} gpiodcxx)
30target_link_libraries(${PROJECT_NAME} systemd)
31target_link_libraries(${PROJECT_NAME} sdbusplus)
32
33target_compile_definitions (
34 ${PROJECT_NAME} PRIVATE $<$<BOOL:${CHASSIS_SYSTEM_RESET}>:
35 -DCHASSIS_SYSTEM_RESET>
36 ${PROJECT_NAME} PRIVATE $<$<BOOL:${USE_PLT_RST}>:
37 -DUSE_PLT_RST>
38)
39
40install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
41
42# Temporarily disable rtti
43# See https://github.com/chriskohlhoff/asio/issues/533
44#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
45#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti")
46
47set(
48 SERVICE_FILES
49 ${PROJECT_SOURCE_DIR}/service_files/chassis-system-reset.service
50 ${PROJECT_SOURCE_DIR}/service_files/chassis-system-reset.target
51 ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.Chassis.Control.Power@.service
52 )
53
54set(
55 CONFIG_FILE
56 ${PROJECT_SOURCE_DIR}/config/power-config-host0.json
57 )
58
59install(FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)
60install(FILES ${CONFIG_FILE} DESTINATION /usr/share/x86-power-control/)