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