blob: ff6638b4ed795475cf3bd1da75653960be83adf3 [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")
Matt Spinler8f2c95a2018-11-05 15:17:29 -060013set(GPIO_BASE_LABEL_NAME "1e780000.gpio")
Matt Spinler93894f62018-11-05 15:31:18 -060014set(LONG_PRESS_TIME_MS 3000)
Matt Spinler963c65f2018-11-26 14:46:41 -060015set(CHASSIS_STATE_OBJECT_NAME "xyz/openbmc_project/state/chassis")
16set(HOST_STATE_OBJECT_NAME "xyz/openbmc_project/state/host")
Matt Spinler69f93512018-11-26 14:55:58 -060017set(ID_LED_GROUP "enclosure_identify" CACHE STRING "The identify LED group name")
Kuiying Wanga9d39e32018-08-14 13:47:32 +080018
19add_definitions(-DPOWER_DBUS_OBJECT_NAME="/${POWER_DBUS_OBJECT_NAME}0")
20add_definitions(-DRESET_DBUS_OBJECT_NAME="/${RESET_DBUS_OBJECT_NAME}0")
21add_definitions(-DID_DBUS_OBJECT_NAME="/${ID_DBUS_OBJECT_NAME}0")
Matt Spinler8f2c95a2018-11-05 15:17:29 -060022add_definitions(-DGPIO_BASE_LABEL_NAME="${GPIO_BASE_LABEL_NAME}")
Matt Spinler93894f62018-11-05 15:31:18 -060023add_definitions(-DLONG_PRESS_TIME_MS=${LONG_PRESS_TIME_MS})
Matt Spinler963c65f2018-11-26 14:46:41 -060024add_definitions(-DHOST_STATE_OBJECT_NAME="/${HOST_STATE_OBJECT_NAME}0")
25add_definitions(-DCHASSIS_STATE_OBJECT_NAME="/${CHASSIS_STATE_OBJECT_NAME}0")
26
Kuiying Wanga9d39e32018-08-14 13:47:32 +080027set(SRC_FILES src/power_button.cpp
28 src/reset_button.cpp
29 src/id_button.cpp
30 src/main.cpp
31 src/gpio.cpp
32)
33
Matt Spinlerfb35a322018-11-26 14:30:30 -060034set(HANDLER_SRC_FILES
35 src/button_handler_main.cpp
36 src/button_handler.cpp
37)
38
39option (LOOKUP_GPIO_BASE
Matt Spinler8f2c95a2018-11-05 15:17:29 -060040 "Look up the GPIO base value in /sys/class/gpio. Otherwise use a base of 0." ON
41)
42
43configure_file (settings.hpp.in ${CMAKE_BINARY_DIR}/inc/settings.hpp)
Matt Spinler3c3ebbc2018-11-15 12:46:33 -060044include_directories(${CMAKE_BINARY_DIR}/inc)
Matt Spinler8f2c95a2018-11-05 15:17:29 -060045
Kuiying Wanga9d39e32018-08-14 13:47:32 +080046# import sdbusplus
47find_package(PkgConfig REQUIRED)
48pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED)
49include_directories(${SDBUSPLUSPLUS_INCLUDE_DIRS})
50link_directories(${SDBUSPLUSPLUS_LIBRARY_DIRS})
51find_program(SDBUSPLUSPLUS sdbus++)
52
53# import phosphor-logging
54find_package(PkgConfig REQUIRED)
55pkg_check_modules(LOGGING phosphor-logging REQUIRED)
56include_directories(${LOGGING_INCLUDE_DIRS})
57link_directories(${LOGGING_LIBRARY_DIRS})
58
59# phosphor-dbus-interfaces
60find_package(PkgConfig REQUIRED)
61pkg_check_modules(DBUSINTERFACE phosphor-dbus-interfaces REQUIRED)
62include_directories(${DBUSINTERFACE_INCLUDE_DIRS})
63link_directories(${DBUSINTERFACE_LIBRARY_DIRS})
64
65add_executable(${PROJECT_NAME} ${SRC_FILES} )
66target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus -lstdc++fs")
67
Matt Spinlerfb35a322018-11-26 14:30:30 -060068add_executable(button-handler ${HANDLER_SRC_FILES})
69target_link_libraries(button-handler "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus")
70
Matt Spinlerf6542672018-11-15 16:22:48 -060071set (
72 SERVICE_FILES
73 ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.Chassis.Buttons.service
Matt Spinler1ac94e22018-11-26 15:00:50 -060074 ${PROJECT_SOURCE_DIR}/service_files/phosphor-button-handler.service
Matt Spinlerf6542672018-11-15 16:22:48 -060075)
76
77install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)
Patrick Venture69101222019-03-28 13:37:08 -070078install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
79install (TARGETS button-handler DESTINATION ${CMAKE_INSTALL_BINDIR})