blob: 790a95b54c626004e63b1b7644c447fe1ecaf5c0 [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 Spinler8f2c95a2018-11-05 15:17:29 -060028option (
29 LOOKUP_GPIO_BASE
30 "Look up the GPIO base value in /sys/class/gpio. Otherwise use a base of 0." ON
31)
32
33configure_file (settings.hpp.in ${CMAKE_BINARY_DIR}/inc/settings.hpp)
Matt Spinler3c3ebbc2018-11-15 12:46:33 -060034include_directories(${CMAKE_BINARY_DIR}/inc)
Matt Spinler8f2c95a2018-11-05 15:17:29 -060035
Kuiying Wanga9d39e32018-08-14 13:47:32 +080036# import sdbusplus
37find_package(PkgConfig REQUIRED)
38pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED)
39include_directories(${SDBUSPLUSPLUS_INCLUDE_DIRS})
40link_directories(${SDBUSPLUSPLUS_LIBRARY_DIRS})
41find_program(SDBUSPLUSPLUS sdbus++)
42
43# import phosphor-logging
44find_package(PkgConfig REQUIRED)
45pkg_check_modules(LOGGING phosphor-logging REQUIRED)
46include_directories(${LOGGING_INCLUDE_DIRS})
47link_directories(${LOGGING_LIBRARY_DIRS})
48
49# phosphor-dbus-interfaces
50find_package(PkgConfig REQUIRED)
51pkg_check_modules(DBUSINTERFACE phosphor-dbus-interfaces REQUIRED)
52include_directories(${DBUSINTERFACE_INCLUDE_DIRS})
53link_directories(${DBUSINTERFACE_LIBRARY_DIRS})
54
55add_executable(${PROJECT_NAME} ${SRC_FILES} )
56target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus -lstdc++fs")
57
Matt Spinlerf6542672018-11-15 16:22:48 -060058set (
59 SERVICE_FILES
60 ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.Chassis.Buttons.service
61)
62
63install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)
Matt Spinler06c59682018-11-15 11:32:09 -060064install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_SBINDIR})