blob: 5cc49442f128782b435219fe1d25cc1fd79674bf [file] [log] [blame]
Jason M. Billsd1e40602019-05-09 11:43:51 -07001cmake_minimum_required (VERSION 3.6)
2project (peci-pcie CXX)
Jason M. Billsbce86a62020-10-08 16:03:47 -07003include (ExternalProject)
Ed Tanousbe1fdbf2022-09-01 11:31:54 -07004set (CMAKE_CXX_STANDARD 20)
Jason M. Billsd1e40602019-05-09 11:43:51 -07005set (CMAKE_CXX_STANDARD_REQUIRED ON)
6
7add_executable (peci-pcie src/peci_pcie.cpp)
8
Jason M. Billsee6d80b2021-06-11 07:37:30 -07009option (
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. Bills3b1665a2021-06-11 13:35:04 -070015option (
16 USE_RDENDPOINTCFG
17 "Use the RdEndpointConfig PECI command to read PCI data"
18 OFF
19)
20
Jason M. Billsee6d80b2021-06-11 07:37:30 -070021target_compile_definitions (
22 peci-pcie PRIVATE $<$<BOOL:${WAIT_FOR_OS_STANDBY}>: -DWAIT_FOR_OS_STANDBY>
Jason M. Bills3b1665a2021-06-11 13:35:04 -070023 peci-pcie PRIVATE $<$<BOOL:${USE_RDENDPOINTCFG}>: -DUSE_RDENDPOINTCFG>
Jason M. Billsee6d80b2021-06-11 07:37:30 -070024)
25
Jason M. Billsbce86a62020-10-08 16:03:47 -070026option (YOCTO "Enable Building in Yocto" OFF)
27
28if (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)
43endif ()
44
Jason M. Billsd1e40602019-05-09 11:43:51 -070045target_include_directories (peci-pcie PRIVATE ${CMAKE_SOURCE_DIR})
46
47target_link_libraries (peci-pcie peci sdbusplus -lsystemd)
48
49include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
50
51install (TARGETS peci-pcie
52 RUNTIME DESTINATION bin
53 LIBRARY DESTINATION lib
54 ARCHIVE DESTINATION lib/static)
55
56find_package (Boost 1.66 REQUIRED)
57include_directories (${BOOST_SRC_DIR})
58
59add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY)
60add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED)
61add_definitions (-DBOOST_ALL_NO_LIB)
62add_definitions (-DBOOST_NO_RTTI)
63add_definitions (-DBOOST_NO_TYPEID)
64add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
65
66set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
67set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-rtti")
68
69set (SERVICE_FILES
70 ${PROJECT_SOURCE_DIR}/service_files/xyz.openbmc_project.PCIe.service)
71install (FILES ${SERVICE_FILES} DESTINATION /lib/systemd/system/)