Cheng C Yang | eecaf82 | 2019-12-19 00:34:23 +0800 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 3.2 FATAL_ERROR) |
| 2 | include (ExternalProject) |
| 3 | set (CMAKE_CXX_STANDARD 17) |
| 4 | set (CMAKE_CXX_STANDARD_REQUIRED ON) |
| 5 | set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
| 6 | set (DBUS_OBJECT_NAME "xyz/openbmc_project/Smbios/MDR_V2") |
| 7 | set (DBUS_INTF_NAME "xyz.openbmc_project.Smbios.MDR_V2") |
| 8 | |
| 9 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") |
| 10 | |
| 11 | include_directories ( |
| 12 | ${CMAKE_CURRENT_SOURCE_DIR}/include/phosphor-dbus-interfaces |
| 13 | ) |
| 14 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 15 | link_directories (${DBUSINTERFACE_LIBRARIES}) |
| 16 | |
| 17 | find_package (PkgConfig REQUIRED) |
| 18 | pkg_check_modules (SYSTEMD libsystemd REQUIRED) |
| 19 | include_directories (${SYSTEMD_INCLUDE_DIRS}) |
| 20 | link_directories (${SYSTEMD_LIBRARY_DIRS}) |
| 21 | |
| 22 | # import sdbusplus |
| 23 | find_package (PkgConfig REQUIRED) |
| 24 | pkg_check_modules (SDBUSPLUSPLUS sdbusplus REQUIRED) |
| 25 | include_directories (${SDBUSPLUSPLUS_INCLUDE_DIRS}) |
| 26 | link_directories (${SDBUSPLUSPLUS_LIBRARY_DIRS}) |
| 27 | |
| 28 | # phosphor-dbus-interfaces |
| 29 | find_package (PkgConfig REQUIRED) |
| 30 | pkg_check_modules (DBUSINTERFACE phosphor-dbus-interfaces REQUIRED) |
| 31 | include_directories (${DBUSINTERFACE_INCLUDE_DIRS}) |
| 32 | link_directories (${DBUSINTERFACE_LIBRARY_DIRS}) |
| 33 | |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 34 | # boost |
| 35 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}/boost-src) |
| 36 | set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/boost-src ${CMAKE_PREFIX_PATH}) |
| 37 | add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) |
| 38 | add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) |
| 39 | add_definitions (-DBOOST_ALL_NO_LIB) |
| 40 | add_definitions (-DBOOST_NO_RTTI) |
| 41 | add_definitions (-DBOOST_NO_TYPEID) |
| 42 | add_definitions (-DBOOST_ASIO_DISABLE_THREADS) |
| 43 | |
Cheng C Yang | 2ca7a0f | 2019-12-19 10:46:42 +0800 | [diff] [blame] | 44 | set (SRC_FILES src/mdrv2.cpp src/mdrv2_main.cpp src/cpu.cpp src/dimm.cpp |
| 45 | src/system.cpp) |
Cheng C Yang | eecaf82 | 2019-12-19 00:34:23 +0800 | [diff] [blame] | 46 | |
| 47 | include_directories (${CMAKE_CURRENT_BINARY_DIR}) |
| 48 | |
| 49 | find_package (PkgConfig REQUIRED) |
| 50 | pkg_check_modules (SDBUSPLUSPLUS sdbusplus REQUIRED) |
| 51 | include_directories (${SDBUSPLUSPLUS_INCLUDE_DIRS}) |
| 52 | link_directories (${SDBUSPLUSPLUS_LIBRARY_DIRS}) |
| 53 | find_program (SDBUSPLUSPLUS sdbus++) |
| 54 | |
| 55 | add_executable (smbiosmdrv2app ${SRC_FILES}) |
| 56 | target_link_libraries (smbiosmdrv2app ${SYSTEMD_LIBRARIES}) |
| 57 | target_link_libraries (smbiosmdrv2app ${DBUSINTERFACE_LIBRARIES}) |
| 58 | target_link_libraries (smbiosmdrv2app ${SDBUSPLUSPLUS_LIBRARIES}) |
| 59 | target_link_libraries (smbiosmdrv2app phosphor_logging) |
| 60 | |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 61 | add_executable (cpuinfoapp src/cpuinfo_main.cpp) |
| 62 | target_link_libraries (cpuinfoapp ${SYSTEMD_LIBRARIES}) |
| 63 | target_link_libraries (cpuinfoapp ${DBUSINTERFACE_LIBRARIES}) |
| 64 | target_link_libraries (cpuinfoapp ${SDBUSPLUSPLUS_LIBRARIES}) |
| 65 | target_link_libraries (cpuinfoapp phosphor_logging) |
| 66 | target_link_libraries (cpuinfoapp i2c) |
| 67 | target_link_libraries (cpuinfoapp peci) |
| 68 | |
| 69 | option (DIMM_DBUS "Expose DIMM D-Bus Interface" ON) |
| 70 | |
| 71 | if (DIMM_DBUS) |
| 72 | target_compile_definitions (smbiosmdrv2app PRIVATE DIMM_DBUS) |
| 73 | endif () |
| 74 | |
| 75 | option (YOCTO "Enable Building in Yocto" OFF) |
| 76 | |
| 77 | if (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) |
| 92 | endif () |
| 93 | |
Kuiying Wang | 3f244c0 | 2020-09-04 10:26:31 +0800 | [diff] [blame] | 94 | install (TARGETS smbiosmdrv2app DESTINATION bin) |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 95 | |
| 96 | install (TARGETS cpuinfoapp |
| 97 | RUNTIME DESTINATION bin |
| 98 | LIBRARY DESTINATION lib |
| 99 | ARCHIVE DESTINATION lib/static) |
| 100 | |
| 101 | set (SERVICE_FILES |
Kuiying Wang | 3f244c0 | 2020-09-04 10:26:31 +0800 | [diff] [blame] | 102 | ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.cpuinfo.service |
| 103 | ${PROJECT_SOURCE_DIR}/service_files/smbios-mdrv2.service) |
Zhikui Ren | 18a5ab9 | 2020-09-01 21:35:20 -0700 | [diff] [blame] | 104 | install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) |