Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR) |
| 2 | project(buttons CXX) |
Patrick Venture | 7e0270e | 2018-11-01 19:41:06 -0700 | [diff] [blame] | 3 | set(CMAKE_CXX_STANDARD 17) |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 4 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 5 | |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 6 | include(GNUInstallDirs) |
| 7 | |
| 8 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) |
| 9 | |
| 10 | set(POWER_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/Power") |
| 11 | set(RESET_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/Reset") |
| 12 | set(ID_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/ID") |
Naveen Moses | 3bd1cfc | 2022-02-14 18:04:20 +0530 | [diff] [blame] | 13 | set(HS_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/HostSelector") |
| 14 | |
Matt Spinler | 8f2c95a | 2018-11-05 15:17:29 -0600 | [diff] [blame] | 15 | set(GPIO_BASE_LABEL_NAME "1e780000.gpio") |
Matt Spinler | 93894f6 | 2018-11-05 15:31:18 -0600 | [diff] [blame] | 16 | set(LONG_PRESS_TIME_MS 3000) |
Matt Spinler | 963c65f | 2018-11-26 14:46:41 -0600 | [diff] [blame] | 17 | set(CHASSIS_STATE_OBJECT_NAME "xyz/openbmc_project/state/chassis") |
Naveen Moses | 3bd1cfc | 2022-02-14 18:04:20 +0530 | [diff] [blame] | 18 | set(CHASSISSYSTEM_STATE_OBJECT_NAME "xyz/openbmc_project/state/chassis_system") |
| 19 | |
Matt Spinler | 963c65f | 2018-11-26 14:46:41 -0600 | [diff] [blame] | 20 | set(HOST_STATE_OBJECT_NAME "xyz/openbmc_project/state/host") |
Matt Spinler | 69f9351 | 2018-11-26 14:55:58 -0600 | [diff] [blame] | 21 | set(ID_LED_GROUP "enclosure_identify" CACHE STRING "The identify LED group name") |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 22 | |
| 23 | add_definitions(-DPOWER_DBUS_OBJECT_NAME="/${POWER_DBUS_OBJECT_NAME}0") |
| 24 | add_definitions(-DRESET_DBUS_OBJECT_NAME="/${RESET_DBUS_OBJECT_NAME}0") |
| 25 | add_definitions(-DID_DBUS_OBJECT_NAME="/${ID_DBUS_OBJECT_NAME}0") |
Naveen Moses | 3bd1cfc | 2022-02-14 18:04:20 +0530 | [diff] [blame] | 26 | add_definitions(-DHS_DBUS_OBJECT_NAME="/${HS_DBUS_OBJECT_NAME}") |
| 27 | |
Matt Spinler | 8f2c95a | 2018-11-05 15:17:29 -0600 | [diff] [blame] | 28 | add_definitions(-DGPIO_BASE_LABEL_NAME="${GPIO_BASE_LABEL_NAME}") |
Matt Spinler | 93894f6 | 2018-11-05 15:31:18 -0600 | [diff] [blame] | 29 | add_definitions(-DLONG_PRESS_TIME_MS=${LONG_PRESS_TIME_MS}) |
Naveen Moses | 3bd1cfc | 2022-02-14 18:04:20 +0530 | [diff] [blame] | 30 | add_definitions(-DHOST_STATE_OBJECT_NAME="/${HOST_STATE_OBJECT_NAME}") |
| 31 | add_definitions(-DCHASSIS_STATE_OBJECT_NAME="/${CHASSIS_STATE_OBJECT_NAME}") |
| 32 | add_definitions(-DCHASSISSYSTEM_STATE_OBJECT_NAME="/${CHASSISSYSTEM_STATE_OBJECT_NAME}") |
Matt Spinler | 963c65f | 2018-11-26 14:46:41 -0600 | [diff] [blame] | 33 | |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 34 | set(SRC_FILES src/power_button.cpp |
| 35 | src/reset_button.cpp |
| 36 | src/id_button.cpp |
Naveen Moses | 3bd1cfc | 2022-02-14 18:04:20 +0530 | [diff] [blame] | 37 | src/hostSelector_switch.cpp |
| 38 | |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 39 | src/main.cpp |
| 40 | src/gpio.cpp |
| 41 | ) |
| 42 | |
Matt Spinler | fb35a32 | 2018-11-26 14:30:30 -0600 | [diff] [blame] | 43 | set(HANDLER_SRC_FILES |
| 44 | src/button_handler_main.cpp |
| 45 | src/button_handler.cpp |
| 46 | ) |
| 47 | |
| 48 | option (LOOKUP_GPIO_BASE |
Matt Spinler | 8f2c95a | 2018-11-05 15:17:29 -0600 | [diff] [blame] | 49 | "Look up the GPIO base value in /sys/class/gpio. Otherwise use a base of 0." ON |
| 50 | ) |
| 51 | |
| 52 | configure_file (settings.hpp.in ${CMAKE_BINARY_DIR}/inc/settings.hpp) |
Matt Spinler | 3c3ebbc | 2018-11-15 12:46:33 -0600 | [diff] [blame] | 53 | include_directories(${CMAKE_BINARY_DIR}/inc) |
Matt Spinler | 8f2c95a | 2018-11-05 15:17:29 -0600 | [diff] [blame] | 54 | |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 55 | # import sdbusplus |
| 56 | find_package(PkgConfig REQUIRED) |
| 57 | pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED) |
| 58 | include_directories(${SDBUSPLUSPLUS_INCLUDE_DIRS}) |
| 59 | link_directories(${SDBUSPLUSPLUS_LIBRARY_DIRS}) |
| 60 | find_program(SDBUSPLUSPLUS sdbus++) |
| 61 | |
| 62 | # import phosphor-logging |
| 63 | find_package(PkgConfig REQUIRED) |
| 64 | pkg_check_modules(LOGGING phosphor-logging REQUIRED) |
| 65 | include_directories(${LOGGING_INCLUDE_DIRS}) |
| 66 | link_directories(${LOGGING_LIBRARY_DIRS}) |
| 67 | |
| 68 | # phosphor-dbus-interfaces |
| 69 | find_package(PkgConfig REQUIRED) |
| 70 | pkg_check_modules(DBUSINTERFACE phosphor-dbus-interfaces REQUIRED) |
| 71 | include_directories(${DBUSINTERFACE_INCLUDE_DIRS}) |
| 72 | link_directories(${DBUSINTERFACE_LIBRARY_DIRS}) |
| 73 | |
| 74 | add_executable(${PROJECT_NAME} ${SRC_FILES} ) |
Patrick Williams | 8eca9bb | 2022-06-16 17:11:51 -0500 | [diff] [blame] | 75 | target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus") |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 76 | |
Matt Spinler | fb35a32 | 2018-11-26 14:30:30 -0600 | [diff] [blame] | 77 | add_executable(button-handler ${HANDLER_SRC_FILES}) |
| 78 | target_link_libraries(button-handler "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus") |
| 79 | |
Matt Spinler | f654267 | 2018-11-15 16:22:48 -0600 | [diff] [blame] | 80 | set ( |
| 81 | SERVICE_FILES |
| 82 | ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.Chassis.Buttons.service |
Matt Spinler | 1ac94e2 | 2018-11-26 15:00:50 -0600 | [diff] [blame] | 83 | ${PROJECT_SOURCE_DIR}/service_files/phosphor-button-handler.service |
Matt Spinler | f654267 | 2018-11-15 16:22:48 -0600 | [diff] [blame] | 84 | ) |
| 85 | |
| 86 | install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) |
Patrick Venture | 6910122 | 2019-03-28 13:37:08 -0700 | [diff] [blame] | 87 | install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) |
| 88 | install (TARGETS button-handler DESTINATION ${CMAKE_INSTALL_BINDIR}) |