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