blob: d4e34ed96f41c6fe85a4f8948f184933350881a7 [file] [log] [blame]
Dung Cao956cbfc2021-06-11 09:24:57 +00001cmake_minimum_required (VERSION 3.5 FATAL_ERROR)
2
3cmake_policy (SET CMP0054 NEW)
4
5option (YOCTO "Use YOCTO depedencies system" OFF)
6include (ExternalProject)
7set (CMAKE_CXX_STANDARD 17)
8set (CMAKE_CXX_STANDARD_REQUIRED ON)
9set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
10
11option (USING_ENTITY_MANAGER_DECORATORS
12 "Enable using EM decorators to map FRUs to entity IDs" ON)
13
14set (
15 CMAKE_CXX_FLAGS
16 "${CMAKE_CXX_FLAGS} \
17 -Werror \
18 -Wtype-limits \
19 -Wnull-dereference \
20"
21)
22
23project (ampere-ipmi-oem CXX)
24
25add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY)
26add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED)
27add_definitions (-DBOOST_ALL_NO_LIB)
28add_definitions (-DBOOST_NO_RTTI)
29add_definitions (-DBOOST_NO_TYPEID)
30add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
31add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING)
32add_definitions (-Wno-psabi)
33
34if (NOT YOCTO) # headers that can't be built without yocto
35 include_directories (SYSTEM non-yocto)
36
37 configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt)
38 execute_process (COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
39 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
40 execute_process (COMMAND ${CMAKE_COMMAND} --build .
41 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
42
43 set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH})
44 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/prefix/include)
45 link_directories (${CMAKE_BINARY_DIR}/prefix/lib)
46
47 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src)
48 link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs)
49 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/phosphor-logging-src)
50 link_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src/.libs)
51 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/phosphor-ipmi-host/include)
52 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/ipmid/user_channel)
53 include_directories (SYSTEM ${CMAKE_BINARY_DIR}) # link_directories (${CMAK
54 # E_BINARY_DIR}/sdbusplus-
55 # src/.libs)
56endif ()
57
58if (YOCTO)
59 find_package (PkgConfig REQUIRED)
60 pkg_check_modules (LOGGING phosphor-logging REQUIRED)
61 include_directories (SYSTEM ${LOGGING_INCLUDE_DIRS})
62 link_directories (${LOGGING_LIBRARY_DIRS})
63
64 pkg_check_modules (LIBIPMID libipmid REQUIRED)
65 include_directories (SYSTEM ${LIBIPMID_INCLUDE_DIRS})
66 link_directories (${LIBIPMID_LIBRARY_DIRS})
67
68endif ()
69
70include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
71
72#
73# import OpenSSL (crypto)
74find_package (OpenSSL REQUIRED)
75include_directories (SYSTEM ${OPENSSL_INCLUDE_DIR})
76
77include_directories (SYSTEM ${CMAKE_BINARY_DIR})
78
79add_library (zampoemcmds
80 SHARED
Dung Caoe71dce52021-06-11 10:23:42 +000081 src/bridgingcommands.cpp
Hieu Huynh1463f702021-09-23 03:14:59 +000082 src/appcommands.cpp
83 src/oemcommands.cpp)
Dung Cao956cbfc2021-06-11 09:24:57 +000084
85set_target_properties (zampoemcmds PROPERTIES VERSION "0.1.0")
86set_target_properties (zampoemcmds PROPERTIES SOVERSION "0")
87target_link_libraries (zampoemcmds stdc++fs)
88target_link_libraries (zampoemcmds ipmid)
89target_link_libraries (zampoemcmds sdbusplus)
90target_link_libraries (zampoemcmds phosphor_logging)
91target_link_libraries (zampoemcmds -luserlayer)
92target_link_libraries (zampoemcmds -lchannellayer)
93target_link_libraries (zampoemcmds ${OPENSSL_CRYPTO_LIBRARY})
94target_link_libraries (zampoemcmds gpiodcxx)
95
96install (TARGETS zampoemcmds DESTINATION lib/ipmid-providers)
97
98target_compile_definitions (
99 zampoemcmds PRIVATE
100 $<$<BOOL:${INTEL_PFR_ENABLED}>: -DINTEL_PFR_ENABLED>
101 $<$<BOOL:${BMC_VALIDATION_UNSECURE_FEATURE}>:
102 -DBMC_VALIDATION_UNSECURE_FEATURE>
103 $<$<BOOL:${MDR_V1_SUPPORT}>: -DMDR_V1_SUPPORT>
104 $<$<BOOL:${USING_ENTITY_MANAGER_DECORATORS}>:
105 -DUSING_ENTITY_MANAGER_DECORATORS>
106)