blob: da3ff73778be0e7a796c5314308f74027902811b [file] [log] [blame]
Mohaimen Alsamarai35c1ac42021-04-20 13:16:42 -05001cmake_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
11
12set (
13 CMAKE_CXX_FLAGS
14 "${CMAKE_CXX_FLAGS} \
15 -Werror \
16 -Wtype-limits \
17 -Wnull-dereference \
18"
19)
20
21project (fii-ipmi-oem CXX)
22
23add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY)
24add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED)
25add_definitions (-DBOOST_ALL_NO_LIB)
26add_definitions (-DBOOST_NO_RTTI)
27add_definitions (-DBOOST_NO_TYPEID)
28add_definitions (-DBOOST_ASIO_DISABLE_THREADS)
29add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING)
30add_definitions (-Wno-psabi)
31
32if (NOT YOCTO) # headers that can't be built without yocto
33 include_directories (SYSTEM non-yocto)
34
35 configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt)
36 execute_process (COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
37 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
38 execute_process (COMMAND ${CMAKE_COMMAND} --build .
39 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty)
40
41 set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH})
42 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/prefix/include)
43 link_directories (${CMAKE_BINARY_DIR}/prefix/lib)
44
45 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src)
46 link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs)
47 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/phosphor-logging-src)
48 link_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src/.libs)
49 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/phosphor-ipmi-host/include)
50 include_directories (SYSTEM ${CMAKE_BINARY_DIR}/ipmid/user_channel)
51 include_directories (SYSTEM ${CMAKE_BINARY_DIR}) # link_directories (${CMAK
52 # E_BINARY_DIR}/sdbusplus-
53 # src/.libs)
54endif ()
55
56if (YOCTO)
57 find_package (PkgConfig REQUIRED)
58 pkg_check_modules (LOGGING phosphor-logging REQUIRED)
59 include_directories (SYSTEM ${LOGGING_INCLUDE_DIRS})
60 link_directories (${LOGGING_LIBRARY_DIRS})
61
62 pkg_check_modules (LIBIPMID libipmid REQUIRED)
63 include_directories (SYSTEM ${LIBIPMID_INCLUDE_DIRS})
64 link_directories (${LIBIPMID_LIBRARY_DIRS})
65
66endif ()
67
68include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include)
69
70#
71# import OpenSSL (crypto)
72find_package (OpenSSL REQUIRED)
73include_directories (SYSTEM ${OPENSSL_INCLUDE_DIR})
74
75include_directories (SYSTEM ${CMAKE_BINARY_DIR})
76add_custom_command(OUTPUT include/ipmi-whitelist.hpp
77 COMMAND ./generate-whitelist.py
78 ARGS ipmi-whitelist.conf ${CMAKE_BINARY_DIR}/ipmi-whitelist.hpp
79 MAIN_DEPENDENCY ipmi-whitelist.conf
80 DEPENDS generate-whitelist.py
81 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
82
83add_library (fiioemcmds
84 SHARED
85 src/systemcommands.cpp
Avenash Asai Thambida2cf0d2021-08-26 15:51:47 -050086 src/file_handling.cpp
Mohaimen Alsamarai35c1ac42021-04-20 13:16:42 -050087 src/bioscommands.cpp)
88
89set_target_properties (fiioemcmds PROPERTIES VERSION "0.1.0")
90set_target_properties (fiioemcmds PROPERTIES SOVERSION "0")
91target_link_libraries (fiioemcmds stdc++fs)
92target_link_libraries (fiioemcmds ipmid)
93target_link_libraries (fiioemcmds sdbusplus)
94target_link_libraries (fiioemcmds phosphor_logging)
95target_link_libraries (fiioemcmds -luserlayer)
96target_link_libraries (fiioemcmds -lchannellayer)
97target_link_libraries (fiioemcmds ${OPENSSL_CRYPTO_LIBRARY})
98target_link_libraries (fiioemcmds gpiodcxx)
99
100install (TARGETS fiioemcmds DESTINATION lib/ipmid-providers)
101
102target_compile_definitions (
103 fiioemcmds PRIVATE
104# $<$<BOOL:${INTEL_PFR_ENABLED}>: -DINTEL_PFR_ENABLED>
105# $<$<BOOL:${BMC_VALIDATION_UNSECURE_FEATURE}>:
106# -DBMC_VALIDATION_UNSECURE_FEATURE>
107# $<$<BOOL:${MDR_V1_SUPPORT}>: -DMDR_V1_SUPPORT>
108# $<$<BOOL:${USING_ENTITY_MANAGER_DECORATORS}>:
109# -DUSING_ENTITY_MANAGER_DECORATORS>
110)