blob: d413acec2e50c2056596e61e4d8e7592c4fdd840 [file] [log] [blame]
Cheng C Yangeecaf822019-12-19 00:34:23 +08001cmake_minimum_required (VERSION 3.2 FATAL_ERROR)
2include (ExternalProject)
3set (CMAKE_CXX_STANDARD 17)
4set (CMAKE_CXX_STANDARD_REQUIRED ON)
5set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
6set (DBUS_OBJECT_NAME "xyz/openbmc_project/Smbios/MDR_V2")
7set (DBUS_INTF_NAME "xyz.openbmc_project.Smbios.MDR_V2")
8
9set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
10
11include_directories (
12 ${CMAKE_CURRENT_SOURCE_DIR}/include/phosphor-dbus-interfaces
13)
14include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
15link_directories (${DBUSINTERFACE_LIBRARIES})
16
17find_package (PkgConfig REQUIRED)
18pkg_check_modules (SYSTEMD libsystemd REQUIRED)
19include_directories (${SYSTEMD_INCLUDE_DIRS})
20link_directories (${SYSTEMD_LIBRARY_DIRS})
21
22# import sdbusplus
23find_package (PkgConfig REQUIRED)
24pkg_check_modules (SDBUSPLUSPLUS sdbusplus REQUIRED)
25include_directories (${SDBUSPLUSPLUS_INCLUDE_DIRS})
26link_directories (${SDBUSPLUSPLUS_LIBRARY_DIRS})
27
28# phosphor-dbus-interfaces
29find_package (PkgConfig REQUIRED)
30pkg_check_modules (DBUSINTERFACE phosphor-dbus-interfaces REQUIRED)
31include_directories (${DBUSINTERFACE_INCLUDE_DIRS})
32link_directories (${DBUSINTERFACE_LIBRARY_DIRS})
33
Zhikui Ren18a5ab92020-09-01 21:35:20 -070034# boost
35include_directories (SYSTEM ${CMAKE_BINARY_DIR}/boost-src)
36set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/boost-src ${CMAKE_PREFIX_PATH})
37add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY)
38add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED)
39add_definitions (-DBOOST_ALL_NO_LIB)
40add_definitions (-DBOOST_NO_RTTI)
41add_definitions (-DBOOST_NO_TYPEID)
42add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
43
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +080044set (SRC_FILES src/mdrv2.cpp src/mdrv2_main.cpp src/cpu.cpp src/dimm.cpp
45 src/system.cpp)
Cheng C Yangeecaf822019-12-19 00:34:23 +080046
47include_directories (${CMAKE_CURRENT_BINARY_DIR})
48
49find_package (PkgConfig REQUIRED)
50pkg_check_modules (SDBUSPLUSPLUS sdbusplus REQUIRED)
51include_directories (${SDBUSPLUSPLUS_INCLUDE_DIRS})
52link_directories (${SDBUSPLUSPLUS_LIBRARY_DIRS})
53find_program (SDBUSPLUSPLUS sdbus++)
54
55add_executable (smbiosmdrv2app ${SRC_FILES})
56target_link_libraries (smbiosmdrv2app ${SYSTEMD_LIBRARIES})
57target_link_libraries (smbiosmdrv2app ${DBUSINTERFACE_LIBRARIES})
58target_link_libraries (smbiosmdrv2app ${SDBUSPLUSPLUS_LIBRARIES})
59target_link_libraries (smbiosmdrv2app phosphor_logging)
60
Zhikui Ren18a5ab92020-09-01 21:35:20 -070061add_executable (cpuinfoapp src/cpuinfo_main.cpp)
62target_link_libraries (cpuinfoapp ${SYSTEMD_LIBRARIES})
63target_link_libraries (cpuinfoapp ${DBUSINTERFACE_LIBRARIES})
64target_link_libraries (cpuinfoapp ${SDBUSPLUSPLUS_LIBRARIES})
65target_link_libraries (cpuinfoapp phosphor_logging)
66target_link_libraries (cpuinfoapp i2c)
67target_link_libraries (cpuinfoapp peci)
68
69option (DIMM_DBUS "Expose DIMM D-Bus Interface" ON)
70
71if (DIMM_DBUS)
72 target_compile_definitions (smbiosmdrv2app PRIVATE DIMM_DBUS)
73endif ()
74
75option (YOCTO "Enable Building in Yocto" OFF)
76
77if (NOT YOCTO)
78 add_dependencies (cpuinfoapp libpeci)
79 externalproject_add (libpeci PREFIX ${CMAKE_BINARY_DIR}/libpeci
80 GIT_REPOSITORY https://github.com/openbmc/libpeci.git
81 GIT_TAG a2ceec2aa139277cebb62e1eda449ef60fa4c962
82 INSTALL_COMMAND "")
83
84 externalproject_get_property (libpeci SOURCE_DIR)
85 include_directories (${SOURCE_DIR})
86
87 externalproject_get_property (libpeci BINARY_DIR)
88 add_library (peci SHARED IMPORTED)
89 set_target_properties (peci
90 PROPERTIES IMPORTED_LOCATION
91 ${BINARY_DIR}/libpeci.so)
92endif ()
93
Kuiying Wang3f244c02020-09-04 10:26:31 +080094install (TARGETS smbiosmdrv2app DESTINATION bin)
Zhikui Ren18a5ab92020-09-01 21:35:20 -070095
96install (TARGETS cpuinfoapp
97 RUNTIME DESTINATION bin
98 LIBRARY DESTINATION lib
99 ARCHIVE DESTINATION lib/static)
100
101set (SERVICE_FILES
Kuiying Wang3f244c02020-09-04 10:26:31 +0800102 ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.cpuinfo.service
103 ${PROJECT_SOURCE_DIR}/service_files/smbios-mdrv2.service)
Zhikui Ren18a5ab92020-09-01 21:35:20 -0700104install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)