Jason M. Bills | d1e4060 | 2019-05-09 11:43:51 -0700 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 3.6) |
| 2 | project (peci-pcie CXX) |
Jason M. Bills | bce86a6 | 2020-10-08 16:03:47 -0700 | [diff] [blame] | 3 | include (ExternalProject) |
Jason M. Bills | d1e4060 | 2019-05-09 11:43:51 -0700 | [diff] [blame] | 4 | set (CMAKE_CXX_STANDARD 17) |
| 5 | set (CMAKE_CXX_STANDARD_REQUIRED ON) |
| 6 | |
| 7 | add_executable (peci-pcie src/peci_pcie.cpp) |
| 8 | |
Jason M. Bills | ee6d80b | 2021-06-11 07:37:30 -0700 | [diff] [blame] | 9 | option ( |
| 10 | WAIT_FOR_OS_STANDBY |
| 11 | "Wait for the OS Standby state to indicate that BIOS is complete before starting the PCIe scan" |
| 12 | OFF |
| 13 | ) |
| 14 | |
Jason M. Bills | 3b1665a | 2021-06-11 13:35:04 -0700 | [diff] [blame] | 15 | option ( |
| 16 | USE_RDENDPOINTCFG |
| 17 | "Use the RdEndpointConfig PECI command to read PCI data" |
| 18 | OFF |
| 19 | ) |
| 20 | |
Jason M. Bills | ee6d80b | 2021-06-11 07:37:30 -0700 | [diff] [blame] | 21 | target_compile_definitions ( |
| 22 | peci-pcie PRIVATE $<$<BOOL:${WAIT_FOR_OS_STANDBY}>: -DWAIT_FOR_OS_STANDBY> |
Jason M. Bills | 3b1665a | 2021-06-11 13:35:04 -0700 | [diff] [blame] | 23 | peci-pcie PRIVATE $<$<BOOL:${USE_RDENDPOINTCFG}>: -DUSE_RDENDPOINTCFG> |
Jason M. Bills | ee6d80b | 2021-06-11 07:37:30 -0700 | [diff] [blame] | 24 | ) |
| 25 | |
Jason M. Bills | bce86a6 | 2020-10-08 16:03:47 -0700 | [diff] [blame] | 26 | option (YOCTO "Enable Building in Yocto" OFF) |
| 27 | |
| 28 | if (NOT YOCTO) |
| 29 | add_dependencies (peci-pcie libpeci) |
| 30 | externalproject_add (libpeci PREFIX ${CMAKE_BINARY_DIR}/libpeci |
| 31 | GIT_REPOSITORY https://github.com/openbmc/libpeci.git |
| 32 | GIT_TAG bc641112abc99b4a972665aa984023a6713a21ac |
| 33 | INSTALL_COMMAND "") |
| 34 | |
| 35 | externalproject_get_property (libpeci SOURCE_DIR) |
| 36 | include_directories (${SOURCE_DIR}) |
| 37 | |
| 38 | externalproject_get_property (libpeci BINARY_DIR) |
| 39 | add_library (peci SHARED IMPORTED) |
| 40 | set_target_properties (peci |
| 41 | PROPERTIES IMPORTED_LOCATION |
| 42 | ${BINARY_DIR}/libpeci.so) |
| 43 | endif () |
| 44 | |
Jason M. Bills | d1e4060 | 2019-05-09 11:43:51 -0700 | [diff] [blame] | 45 | target_include_directories (peci-pcie PRIVATE ${CMAKE_SOURCE_DIR}) |
| 46 | |
| 47 | target_link_libraries (peci-pcie peci sdbusplus -lsystemd) |
| 48 | |
| 49 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 50 | |
| 51 | install (TARGETS peci-pcie |
| 52 | RUNTIME DESTINATION bin |
| 53 | LIBRARY DESTINATION lib |
| 54 | ARCHIVE DESTINATION lib/static) |
| 55 | |
| 56 | find_package (Boost 1.66 REQUIRED) |
| 57 | include_directories (${BOOST_SRC_DIR}) |
| 58 | |
| 59 | add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) |
| 60 | add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) |
| 61 | add_definitions (-DBOOST_ALL_NO_LIB) |
| 62 | add_definitions (-DBOOST_NO_RTTI) |
| 63 | add_definitions (-DBOOST_NO_TYPEID) |
| 64 | add_definitions (-DBOOST_ASIO_DISABLE_THREADS) |
| 65 | |
| 66 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti") |
| 67 | set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti") |
| 68 | |
| 69 | set (SERVICE_FILES |
| 70 | ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.PCIe.service) |
| 71 | install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/) |