blob: 1b496061e5d868a299fb61aadaf3d29aede5f6ae [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
Zhikui Ren77455892020-11-19 12:29:44 -08009# disable now to wa boost bug chriskohlhoff/asio#533
10# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
Cheng C Yangeecaf822019-12-19 00:34:23 +080011
Cheng C Yangeecaf822019-12-19 00:34:23 +080012include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
13link_directories (${DBUSINTERFACE_LIBRARIES})
14
15find_package (PkgConfig REQUIRED)
Jonathan Doman94c94bf2020-10-05 23:25:45 -070016
Cheng C Yangeecaf822019-12-19 00:34:23 +080017pkg_check_modules (SYSTEMD libsystemd REQUIRED)
18include_directories (${SYSTEMD_INCLUDE_DIRS})
19link_directories (${SYSTEMD_LIBRARY_DIRS})
20
21# import sdbusplus
Cheng C Yangeecaf822019-12-19 00:34:23 +080022pkg_check_modules (SDBUSPLUSPLUS sdbusplus REQUIRED)
23include_directories (${SDBUSPLUSPLUS_INCLUDE_DIRS})
24link_directories (${SDBUSPLUSPLUS_LIBRARY_DIRS})
Jonathan Doman94c94bf2020-10-05 23:25:45 -070025find_program (SDBUSPLUSPLUS sdbus++)
Cheng C Yangeecaf822019-12-19 00:34:23 +080026
27# phosphor-dbus-interfaces
Cheng C Yangeecaf822019-12-19 00:34:23 +080028pkg_check_modules (DBUSINTERFACE phosphor-dbus-interfaces REQUIRED)
29include_directories (${DBUSINTERFACE_INCLUDE_DIRS})
30link_directories (${DBUSINTERFACE_LIBRARY_DIRS})
31
Zhikui Ren18a5ab92020-09-01 21:35:20 -070032# boost
33include_directories (SYSTEM ${CMAKE_BINARY_DIR}/boost-src)
34set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/boost-src ${CMAKE_PREFIX_PATH})
35add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY)
36add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED)
37add_definitions (-DBOOST_ALL_NO_LIB)
38add_definitions (-DBOOST_NO_RTTI)
39add_definitions (-DBOOST_NO_TYPEID)
40add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
41
Cheng C Yang2ca7a0f2019-12-19 10:46:42 +080042set (SRC_FILES src/mdrv2.cpp src/mdrv2_main.cpp src/cpu.cpp src/dimm.cpp
43 src/system.cpp)
Cheng C Yangeecaf822019-12-19 00:34:23 +080044
45include_directories (${CMAKE_CURRENT_BINARY_DIR})
46
Cheng C Yangeecaf822019-12-19 00:34:23 +080047add_executable (smbiosmdrv2app ${SRC_FILES})
48target_link_libraries (smbiosmdrv2app ${SYSTEMD_LIBRARIES})
49target_link_libraries (smbiosmdrv2app ${DBUSINTERFACE_LIBRARIES})
50target_link_libraries (smbiosmdrv2app ${SDBUSPLUSPLUS_LIBRARIES})
51target_link_libraries (smbiosmdrv2app phosphor_logging)
52
Jonathan Doman94c94bf2020-10-05 23:25:45 -070053add_executable (cpuinfoapp src/cpuinfo_main.cpp src/speed_select.cpp)
Zhikui Ren18a5ab92020-09-01 21:35:20 -070054target_link_libraries (cpuinfoapp ${SYSTEMD_LIBRARIES})
55target_link_libraries (cpuinfoapp ${DBUSINTERFACE_LIBRARIES})
56target_link_libraries (cpuinfoapp ${SDBUSPLUSPLUS_LIBRARIES})
57target_link_libraries (cpuinfoapp phosphor_logging)
58target_link_libraries (cpuinfoapp i2c)
59target_link_libraries (cpuinfoapp peci)
60
61option (DIMM_DBUS "Expose DIMM D-Bus Interface" ON)
62
63if (DIMM_DBUS)
64 target_compile_definitions (smbiosmdrv2app PRIVATE DIMM_DBUS)
65endif ()
66
67option (YOCTO "Enable Building in Yocto" OFF)
68
69if (NOT YOCTO)
70 add_dependencies (cpuinfoapp libpeci)
71 externalproject_add (libpeci PREFIX ${CMAKE_BINARY_DIR}/libpeci
72 GIT_REPOSITORY https://github.com/openbmc/libpeci.git
73 GIT_TAG a2ceec2aa139277cebb62e1eda449ef60fa4c962
74 INSTALL_COMMAND "")
75
76 externalproject_get_property (libpeci SOURCE_DIR)
77 include_directories (${SOURCE_DIR})
78
79 externalproject_get_property (libpeci BINARY_DIR)
80 add_library (peci SHARED IMPORTED)
81 set_target_properties (peci
82 PROPERTIES IMPORTED_LOCATION
83 ${BINARY_DIR}/libpeci.so)
84endif ()
85
Kuiying Wang3f244c02020-09-04 10:26:31 +080086install (TARGETS smbiosmdrv2app DESTINATION bin)
Zhikui Ren18a5ab92020-09-01 21:35:20 -070087
88install (TARGETS cpuinfoapp
89 RUNTIME DESTINATION bin
90 LIBRARY DESTINATION lib
91 ARCHIVE DESTINATION lib/static)
92
93set (SERVICE_FILES
Kuiying Wang3f244c02020-09-04 10:26:31 +080094 ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.cpuinfo.service
95 ${PROJECT_SOURCE_DIR}/service_files/smbios-mdrv2.service)
Zhikui Ren18a5ab92020-09-01 21:35:20 -070096install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)