blob: 594d839699c93ca0e241f888aef25a6c422cbf45 [file] [log] [blame]
Kuiying Wang3a044402019-02-19 15:00:11 +08001cmake_minimum_required(VERSION 2.8.10 FATAL_ERROR)
2project(post-code-manager CXX)
3set(CMAKE_CXX_STANDARD 17)
4set(CMAKE_CXX_STANDARD_REQUIRED ON)
5
6set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
7include(GNUInstallDirs)
8include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc)
9include_directories(${CMAKE_CURRENT_BINARY_DIR})
10
11set(DBUS_OBJECT_NAME "xyz/openbmc_project/State/Boot/PostCode")
12set(DBUS_INTF_NAME "xyz.openbmc_project.State.Boot.PostCode")
13
14add_definitions(-DDBUS_OBJECT_NAME="/${DBUS_OBJECT_NAME}")
15add_definitions(-DDBUS_INTF_NAME="${DBUS_INTF_NAME}")
16set(SRC_FILES src/post_code.cpp
17 src/main.cpp )
18set ( SERVICE_FILES
19 service_files/xyz.openbmc_project.State.Boot.PostCode.service )
20
21# import sdbusplus
22find_package(PkgConfig REQUIRED)
23pkg_check_modules(SDBUSPLUSPLUS sdbusplus REQUIRED)
24include_directories(${SDBUSPLUSPLUS_INCLUDE_DIRS})
25link_directories(${SDBUSPLUSPLUS_LIBRARY_DIRS})
26find_program(SDBUSPLUSPLUS sdbus++)
27
28# import phosphor-logging
29find_package(PkgConfig REQUIRED)
30pkg_check_modules(LOGGING phosphor-logging REQUIRED)
31include_directories(${LOGGING_INCLUDE_DIRS})
32link_directories(${LOGGING_LIBRARY_DIRS})
33
34# phosphor-dbus-interfaces
35find_package(PkgConfig REQUIRED)
36pkg_check_modules(DBUSINTERFACE phosphor-dbus-interfaces REQUIRED)
37include_directories(${DBUSINTERFACE_INCLUDE_DIRS})
38link_directories(${DBUSINTERFACE_LIBRARY_DIRS})
39
40add_executable(${PROJECT_NAME} ${SRC_FILES})
41target_link_libraries(${PROJECT_NAME} ${DBUSINTERFACE_LIBRARIES} )
42target_link_libraries(${PROJECT_NAME} "${SDBUSPLUSPLUS_LIBRARIES} -lstdc++fs -lphosphor_dbus")
43
44install (TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_BINDIR})
45install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)