blob: 51155012b8862f43836b786a1325cf9c5f7c7102 [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
6set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
7set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
8
9include(GNUInstallDirs)
10
11include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
12
13set(POWER_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/Power")
14set(RESET_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/Reset")
15set(ID_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/ID")
Matt Spinler8f2c95a2018-11-05 15:17:29 -060016set(GPIO_BASE_LABEL_NAME "1e780000.gpio")
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}")
Kuiying Wanga9d39e32018-08-14 13:47:32 +080022set(SRC_FILES src/power_button.cpp
23 src/reset_button.cpp
24 src/id_button.cpp
25 src/main.cpp
26 src/gpio.cpp
27)
28
Matt Spinler8f2c95a2018-11-05 15:17:29 -060029option (
30 LOOKUP_GPIO_BASE
31 "Look up the GPIO base value in /sys/class/gpio. Otherwise use a base of 0." ON
32)
33
34configure_file (settings.hpp.in ${CMAKE_BINARY_DIR}/inc/settings.hpp)
35
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
58install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})