blob: c4e8483d3b7f34a01af0c12c32b885b91238a1e8 [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")
Kuiying Wanga9d39e32018-08-14 13:47:32 +080017
18add_definitions(-DPOWER_DBUS_OBJECT_NAME="/${POWER_DBUS_OBJECT_NAME}0")
19add_definitions(-DRESET_DBUS_OBJECT_NAME="/${RESET_DBUS_OBJECT_NAME}0")
20add_definitions(-DID_DBUS_OBJECT_NAME="/${ID_DBUS_OBJECT_NAME}0")
Matt Spinler8f2c95a2018-11-05 15:17:29 -060021add_definitions(-DGPIO_BASE_LABEL_NAME="${GPIO_BASE_LABEL_NAME}")
Matt Spinler93894f62018-11-05 15:31:18 -060022add_definitions(-DLONG_PRESS_TIME_MS=${LONG_PRESS_TIME_MS})
Matt Spinler963c65f2018-11-26 14:46:41 -060023add_definitions(-DHOST_STATE_OBJECT_NAME="/${HOST_STATE_OBJECT_NAME}0")
24add_definitions(-DCHASSIS_STATE_OBJECT_NAME="/${CHASSIS_STATE_OBJECT_NAME}0")
25
Kuiying Wanga9d39e32018-08-14 13:47:32 +080026set(SRC_FILES src/power_button.cpp
27 src/reset_button.cpp
28 src/id_button.cpp
29 src/main.cpp
30 src/gpio.cpp
31)
32
Matt Spinlerfb35a322018-11-26 14:30:30 -060033set(HANDLER_SRC_FILES
34 src/button_handler_main.cpp
35 src/button_handler.cpp
36)
37
38option (LOOKUP_GPIO_BASE
Matt Spinler8f2c95a2018-11-05 15:17:29 -060039 "Look up the GPIO base value in /sys/class/gpio. Otherwise use a base of 0." ON
40)
41
42configure_file (settings.hpp.in ${CMAKE_BINARY_DIR}/inc/settings.hpp)
Matt Spinler3c3ebbc2018-11-15 12:46:33 -060043include_directories(${CMAKE_BINARY_DIR}/inc)
Matt Spinler8f2c95a2018-11-05 15:17:29 -060044
Kuiying Wanga9d39e32018-08-14 13:47:32 +080045# import sdbusplus
46find_package(PkgConfig REQUIRED)
47pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED)
48include_directories(${SDBUSPLUSPLUS_INCLUDE_DIRS})
49link_directories(${SDBUSPLUSPLUS_LIBRARY_DIRS})
50find_program(SDBUSPLUSPLUS sdbus++)
51
52# import phosphor-logging
53find_package(PkgConfig REQUIRED)
54pkg_check_modules(LOGGING phosphor-logging REQUIRED)
55include_directories(${LOGGING_INCLUDE_DIRS})
56link_directories(${LOGGING_LIBRARY_DIRS})
57
58# phosphor-dbus-interfaces
59find_package(PkgConfig REQUIRED)
60pkg_check_modules(DBUSINTERFACE phosphor-dbus-interfaces REQUIRED)
61include_directories(${DBUSINTERFACE_INCLUDE_DIRS})
62link_directories(${DBUSINTERFACE_LIBRARY_DIRS})
63
64add_executable(${PROJECT_NAME} ${SRC_FILES} )
65target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus -lstdc++fs")
66
Matt Spinlerfb35a322018-11-26 14:30:30 -060067add_executable(button-handler ${HANDLER_SRC_FILES})
68target_link_libraries(button-handler "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus")
69
Matt Spinlerf6542672018-11-15 16:22:48 -060070set (
71 SERVICE_FILES
72 ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.Chassis.Buttons.service
73)
74
75install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)
Matt Spinler06c59682018-11-15 11:32:09 -060076install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_SBINDIR})
Matt Spinlerfb35a322018-11-26 14:30:30 -060077install (TARGETS button-handler DESTINATION ${CMAKE_INSTALL_SBINDIR})