blob: f5c3078e0637041fe042449dc78939d3ca7356c7 [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)
Kuiying Wanga9d39e32018-08-14 13:47:32 +080015
16add_definitions(-DPOWER_DBUS_OBJECT_NAME="/${POWER_DBUS_OBJECT_NAME}0")
17add_definitions(-DRESET_DBUS_OBJECT_NAME="/${RESET_DBUS_OBJECT_NAME}0")
18add_definitions(-DID_DBUS_OBJECT_NAME="/${ID_DBUS_OBJECT_NAME}0")
Matt Spinler8f2c95a2018-11-05 15:17:29 -060019add_definitions(-DGPIO_BASE_LABEL_NAME="${GPIO_BASE_LABEL_NAME}")
Matt Spinler93894f62018-11-05 15:31:18 -060020add_definitions(-DLONG_PRESS_TIME_MS=${LONG_PRESS_TIME_MS})
Kuiying Wanga9d39e32018-08-14 13:47:32 +080021set(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 Spinlerfb35a322018-11-26 14:30:30 -060028set(HANDLER_SRC_FILES
29 src/button_handler_main.cpp
30 src/button_handler.cpp
31)
32
33option (LOOKUP_GPIO_BASE
Matt Spinler8f2c95a2018-11-05 15:17:29 -060034 "Look up the GPIO base value in /sys/class/gpio. Otherwise use a base of 0." ON
35)
36
37configure_file (settings.hpp.in ${CMAKE_BINARY_DIR}/inc/settings.hpp)
Matt Spinler3c3ebbc2018-11-15 12:46:33 -060038include_directories(${CMAKE_BINARY_DIR}/inc)
Matt Spinler8f2c95a2018-11-05 15:17:29 -060039
Kuiying Wanga9d39e32018-08-14 13:47:32 +080040# import sdbusplus
41find_package(PkgConfig REQUIRED)
42pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED)
43include_directories(${SDBUSPLUSPLUS_INCLUDE_DIRS})
44link_directories(${SDBUSPLUSPLUS_LIBRARY_DIRS})
45find_program(SDBUSPLUSPLUS sdbus++)
46
47# import phosphor-logging
48find_package(PkgConfig REQUIRED)
49pkg_check_modules(LOGGING phosphor-logging REQUIRED)
50include_directories(${LOGGING_INCLUDE_DIRS})
51link_directories(${LOGGING_LIBRARY_DIRS})
52
53# phosphor-dbus-interfaces
54find_package(PkgConfig REQUIRED)
55pkg_check_modules(DBUSINTERFACE phosphor-dbus-interfaces REQUIRED)
56include_directories(${DBUSINTERFACE_INCLUDE_DIRS})
57link_directories(${DBUSINTERFACE_LIBRARY_DIRS})
58
59add_executable(${PROJECT_NAME} ${SRC_FILES} )
60target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus -lstdc++fs")
61
Matt Spinlerfb35a322018-11-26 14:30:30 -060062add_executable(button-handler ${HANDLER_SRC_FILES})
63target_link_libraries(button-handler "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus")
64
Matt Spinlerf6542672018-11-15 16:22:48 -060065set (
66 SERVICE_FILES
67 ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.Chassis.Buttons.service
68)
69
70install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)
Matt Spinler06c59682018-11-15 11:32:09 -060071install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_SBINDIR})
Matt Spinlerfb35a322018-11-26 14:30:30 -060072install (TARGETS button-handler DESTINATION ${CMAKE_INSTALL_SBINDIR})