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") |
Matt Spinler | 8f2c95a | 2018-11-05 15:17:29 -0600 | [diff] [blame] | 13 | set(GPIO_BASE_LABEL_NAME "1e780000.gpio") |
Matt Spinler | 93894f6 | 2018-11-05 15:31:18 -0600 | [diff] [blame] | 14 | set(LONG_PRESS_TIME_MS 3000) |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 15 | |
| 16 | add_definitions(-DPOWER_DBUS_OBJECT_NAME="/${POWER_DBUS_OBJECT_NAME}0") |
| 17 | add_definitions(-DRESET_DBUS_OBJECT_NAME="/${RESET_DBUS_OBJECT_NAME}0") |
| 18 | add_definitions(-DID_DBUS_OBJECT_NAME="/${ID_DBUS_OBJECT_NAME}0") |
Matt Spinler | 8f2c95a | 2018-11-05 15:17:29 -0600 | [diff] [blame] | 19 | add_definitions(-DGPIO_BASE_LABEL_NAME="${GPIO_BASE_LABEL_NAME}") |
Matt Spinler | 93894f6 | 2018-11-05 15:31:18 -0600 | [diff] [blame] | 20 | add_definitions(-DLONG_PRESS_TIME_MS=${LONG_PRESS_TIME_MS}) |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 21 | set(SRC_FILES src/power_button.cpp |
| 22 | src/reset_button.cpp |
| 23 | src/id_button.cpp |
| 24 | src/main.cpp |
| 25 | src/gpio.cpp |
| 26 | ) |
| 27 | |
Matt Spinler | fb35a32 | 2018-11-26 14:30:30 -0600 | [diff] [blame^] | 28 | set(HANDLER_SRC_FILES |
| 29 | src/button_handler_main.cpp |
| 30 | src/button_handler.cpp |
| 31 | ) |
| 32 | |
| 33 | option (LOOKUP_GPIO_BASE |
Matt Spinler | 8f2c95a | 2018-11-05 15:17:29 -0600 | [diff] [blame] | 34 | "Look up the GPIO base value in /sys/class/gpio. Otherwise use a base of 0." ON |
| 35 | ) |
| 36 | |
| 37 | configure_file (settings.hpp.in ${CMAKE_BINARY_DIR}/inc/settings.hpp) |
Matt Spinler | 3c3ebbc | 2018-11-15 12:46:33 -0600 | [diff] [blame] | 38 | include_directories(${CMAKE_BINARY_DIR}/inc) |
Matt Spinler | 8f2c95a | 2018-11-05 15:17:29 -0600 | [diff] [blame] | 39 | |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 40 | # import sdbusplus |
| 41 | find_package(PkgConfig REQUIRED) |
| 42 | pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED) |
| 43 | include_directories(${SDBUSPLUSPLUS_INCLUDE_DIRS}) |
| 44 | link_directories(${SDBUSPLUSPLUS_LIBRARY_DIRS}) |
| 45 | find_program(SDBUSPLUSPLUS sdbus++) |
| 46 | |
| 47 | # import phosphor-logging |
| 48 | find_package(PkgConfig REQUIRED) |
| 49 | pkg_check_modules(LOGGING phosphor-logging REQUIRED) |
| 50 | include_directories(${LOGGING_INCLUDE_DIRS}) |
| 51 | link_directories(${LOGGING_LIBRARY_DIRS}) |
| 52 | |
| 53 | # phosphor-dbus-interfaces |
| 54 | find_package(PkgConfig REQUIRED) |
| 55 | pkg_check_modules(DBUSINTERFACE phosphor-dbus-interfaces REQUIRED) |
| 56 | include_directories(${DBUSINTERFACE_INCLUDE_DIRS}) |
| 57 | link_directories(${DBUSINTERFACE_LIBRARY_DIRS}) |
| 58 | |
| 59 | add_executable(${PROJECT_NAME} ${SRC_FILES} ) |
| 60 | target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus -lstdc++fs") |
| 61 | |
Matt Spinler | fb35a32 | 2018-11-26 14:30:30 -0600 | [diff] [blame^] | 62 | add_executable(button-handler ${HANDLER_SRC_FILES}) |
| 63 | target_link_libraries(button-handler "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus") |
| 64 | |
Matt Spinler | f654267 | 2018-11-15 16:22:48 -0600 | [diff] [blame] | 65 | set ( |
| 66 | SERVICE_FILES |
| 67 | ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.Chassis.Buttons.service |
| 68 | ) |
| 69 | |
| 70 | install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) |
Matt Spinler | 06c5968 | 2018-11-15 11:32:09 -0600 | [diff] [blame] | 71 | install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_SBINDIR}) |
Matt Spinler | fb35a32 | 2018-11-26 14:30:30 -0600 | [diff] [blame^] | 72 | install (TARGETS button-handler DESTINATION ${CMAKE_INSTALL_SBINDIR}) |