blob: c6c34adca72bac97e4bc3867441fdb503b3ccc7f [file] [log] [blame]
Kuiying Wanga9d39e32018-08-14 13:47:32 +08001cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
2project(buttons CXX)
Patrick Venture7e0270e2018-11-01 19:41:06 -07003set(CMAKE_CXX_STANDARD 17)
Kuiying Wanga9d39e32018-08-14 13:47:32 +08004set(CMAKE_CXX_STANDARD_REQUIRED ON)
5
Kuiying Wanga9d39e32018-08-14 13:47:32 +08006include(GNUInstallDirs)
7
8include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
9
10set(POWER_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/Power")
11set(RESET_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/Reset")
12set(ID_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/ID")
Naveen Moses3bd1cfc2022-02-14 18:04:20 +053013set(HS_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/HostSelector")
14
Matt Spinler8f2c95a2018-11-05 15:17:29 -060015set(GPIO_BASE_LABEL_NAME "1e780000.gpio")
Matt Spinler93894f62018-11-05 15:31:18 -060016set(LONG_PRESS_TIME_MS 3000)
Matt Spinler963c65f2018-11-26 14:46:41 -060017set(CHASSIS_STATE_OBJECT_NAME "xyz/openbmc_project/state/chassis")
Naveen Moses3bd1cfc2022-02-14 18:04:20 +053018set(CHASSISSYSTEM_STATE_OBJECT_NAME "xyz/openbmc_project/state/chassis_system")
19
Matt Spinler963c65f2018-11-26 14:46:41 -060020set(HOST_STATE_OBJECT_NAME "xyz/openbmc_project/state/host")
Matt Spinler69f93512018-11-26 14:55:58 -060021set(ID_LED_GROUP "enclosure_identify" CACHE STRING "The identify LED group name")
Kuiying Wanga9d39e32018-08-14 13:47:32 +080022
23add_definitions(-DPOWER_DBUS_OBJECT_NAME="/${POWER_DBUS_OBJECT_NAME}0")
24add_definitions(-DRESET_DBUS_OBJECT_NAME="/${RESET_DBUS_OBJECT_NAME}0")
25add_definitions(-DID_DBUS_OBJECT_NAME="/${ID_DBUS_OBJECT_NAME}0")
Naveen Moses3bd1cfc2022-02-14 18:04:20 +053026add_definitions(-DHS_DBUS_OBJECT_NAME="/${HS_DBUS_OBJECT_NAME}")
27
Matt Spinler8f2c95a2018-11-05 15:17:29 -060028add_definitions(-DGPIO_BASE_LABEL_NAME="${GPIO_BASE_LABEL_NAME}")
Matt Spinler93894f62018-11-05 15:31:18 -060029add_definitions(-DLONG_PRESS_TIME_MS=${LONG_PRESS_TIME_MS})
Naveen Moses3bd1cfc2022-02-14 18:04:20 +053030add_definitions(-DHOST_STATE_OBJECT_NAME="/${HOST_STATE_OBJECT_NAME}")
31add_definitions(-DCHASSIS_STATE_OBJECT_NAME="/${CHASSIS_STATE_OBJECT_NAME}")
32add_definitions(-DCHASSISSYSTEM_STATE_OBJECT_NAME="/${CHASSISSYSTEM_STATE_OBJECT_NAME}")
Matt Spinler963c65f2018-11-26 14:46:41 -060033
Kuiying Wanga9d39e32018-08-14 13:47:32 +080034set(SRC_FILES src/power_button.cpp
35 src/reset_button.cpp
36 src/id_button.cpp
Naveen Moses3bd1cfc2022-02-14 18:04:20 +053037 src/hostSelector_switch.cpp
38
Kuiying Wanga9d39e32018-08-14 13:47:32 +080039 src/main.cpp
40 src/gpio.cpp
41)
42
Matt Spinlerfb35a322018-11-26 14:30:30 -060043set(HANDLER_SRC_FILES
44 src/button_handler_main.cpp
45 src/button_handler.cpp
46)
47
48option (LOOKUP_GPIO_BASE
Matt Spinler8f2c95a2018-11-05 15:17:29 -060049 "Look up the GPIO base value in /sys/class/gpio. Otherwise use a base of 0." ON
50)
51
52configure_file (settings.hpp.in ${CMAKE_BINARY_DIR}/inc/settings.hpp)
Matt Spinler3c3ebbc2018-11-15 12:46:33 -060053include_directories(${CMAKE_BINARY_DIR}/inc)
Matt Spinler8f2c95a2018-11-05 15:17:29 -060054
Kuiying Wanga9d39e32018-08-14 13:47:32 +080055# import sdbusplus
56find_package(PkgConfig REQUIRED)
57pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED)
58include_directories(${SDBUSPLUSPLUS_INCLUDE_DIRS})
59link_directories(${SDBUSPLUSPLUS_LIBRARY_DIRS})
60find_program(SDBUSPLUSPLUS sdbus++)
61
62# import phosphor-logging
63find_package(PkgConfig REQUIRED)
64pkg_check_modules(LOGGING phosphor-logging REQUIRED)
65include_directories(${LOGGING_INCLUDE_DIRS})
66link_directories(${LOGGING_LIBRARY_DIRS})
67
68# phosphor-dbus-interfaces
69find_package(PkgConfig REQUIRED)
70pkg_check_modules(DBUSINTERFACE phosphor-dbus-interfaces REQUIRED)
71include_directories(${DBUSINTERFACE_INCLUDE_DIRS})
72link_directories(${DBUSINTERFACE_LIBRARY_DIRS})
73
74add_executable(${PROJECT_NAME} ${SRC_FILES} )
Patrick Williams8eca9bb2022-06-16 17:11:51 -050075target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus")
Kuiying Wanga9d39e32018-08-14 13:47:32 +080076
Matt Spinlerfb35a322018-11-26 14:30:30 -060077add_executable(button-handler ${HANDLER_SRC_FILES})
78target_link_libraries(button-handler "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus")
79
Matt Spinlerf6542672018-11-15 16:22:48 -060080set (
81 SERVICE_FILES
82 ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.Chassis.Buttons.service
Matt Spinler1ac94e22018-11-26 15:00:50 -060083 ${PROJECT_SOURCE_DIR}/service_files/phosphor-button-handler.service
Matt Spinlerf6542672018-11-15 16:22:48 -060084)
85
86install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)
Patrick Venture69101222019-03-28 13:37:08 -070087install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
88install (TARGETS button-handler DESTINATION ${CMAKE_INSTALL_BINDIR})