Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame^] | 1 | cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR) |
| 2 | project(buttons CXX) |
| 3 | set(CMAKE_CXX_STANDARD 14) |
| 4 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
| 5 | |
| 6 | set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) |
| 7 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) |
| 8 | |
| 9 | include(GNUInstallDirs) |
| 10 | |
| 11 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) |
| 12 | |
| 13 | set(POWER_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/Power") |
| 14 | set(RESET_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/Reset") |
| 15 | set(ID_DBUS_OBJECT_NAME "xyz/openbmc_project/Chassis/Buttons/ID") |
| 16 | |
| 17 | add_definitions(-DPOWER_DBUS_OBJECT_NAME="/${POWER_DBUS_OBJECT_NAME}0") |
| 18 | add_definitions(-DRESET_DBUS_OBJECT_NAME="/${RESET_DBUS_OBJECT_NAME}0") |
| 19 | add_definitions(-DID_DBUS_OBJECT_NAME="/${ID_DBUS_OBJECT_NAME}0") |
| 20 | set(SRC_FILES src/power_button.cpp |
| 21 | src/reset_button.cpp |
| 22 | src/id_button.cpp |
| 23 | src/main.cpp |
| 24 | src/gpio.cpp |
| 25 | ) |
| 26 | |
| 27 | # import sdbusplus |
| 28 | find_package(PkgConfig REQUIRED) |
| 29 | pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED) |
| 30 | include_directories(${SDBUSPLUSPLUS_INCLUDE_DIRS}) |
| 31 | link_directories(${SDBUSPLUSPLUS_LIBRARY_DIRS}) |
| 32 | find_program(SDBUSPLUSPLUS sdbus++) |
| 33 | |
| 34 | # import phosphor-logging |
| 35 | find_package(PkgConfig REQUIRED) |
| 36 | pkg_check_modules(LOGGING phosphor-logging REQUIRED) |
| 37 | include_directories(${LOGGING_INCLUDE_DIRS}) |
| 38 | link_directories(${LOGGING_LIBRARY_DIRS}) |
| 39 | |
| 40 | # phosphor-dbus-interfaces |
| 41 | find_package(PkgConfig REQUIRED) |
| 42 | pkg_check_modules(DBUSINTERFACE phosphor-dbus-interfaces REQUIRED) |
| 43 | include_directories(${DBUSINTERFACE_INCLUDE_DIRS}) |
| 44 | link_directories(${DBUSINTERFACE_LIBRARY_DIRS}) |
| 45 | |
| 46 | add_executable(${PROJECT_NAME} ${SRC_FILES} ) |
| 47 | target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lphosphor_dbus -lstdc++fs") |
| 48 | |
| 49 | install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR}) |