Dung Cao | 956cbfc | 2021-06-11 09:24:57 +0000 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 3.5 FATAL_ERROR) |
| 2 | |
| 3 | cmake_policy (SET CMP0054 NEW) |
| 4 | |
| 5 | option (YOCTO "Use YOCTO depedencies system" OFF) |
| 6 | include (ExternalProject) |
| 7 | set (CMAKE_CXX_STANDARD 17) |
| 8 | set (CMAKE_CXX_STANDARD_REQUIRED ON) |
| 9 | set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
| 10 | |
| 11 | option (USING_ENTITY_MANAGER_DECORATORS |
| 12 | "Enable using EM decorators to map FRUs to entity IDs" ON) |
| 13 | |
| 14 | set ( |
| 15 | CMAKE_CXX_FLAGS |
| 16 | "${CMAKE_CXX_FLAGS} \ |
| 17 | -Werror \ |
| 18 | -Wtype-limits \ |
| 19 | -Wnull-dereference \ |
| 20 | " |
| 21 | ) |
| 22 | |
| 23 | project (ampere-ipmi-oem CXX) |
| 24 | |
| 25 | add_definitions (-DBOOST_ERROR_CODE_HEADER_ONLY) |
| 26 | add_definitions (-DBOOST_SYSTEM_NO_DEPRECATED) |
| 27 | add_definitions (-DBOOST_ALL_NO_LIB) |
| 28 | add_definitions (-DBOOST_NO_RTTI) |
| 29 | add_definitions (-DBOOST_NO_TYPEID) |
| 30 | add_definitions (-DBOOST_ASIO_DISABLE_THREADS) |
| 31 | add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING) |
| 32 | add_definitions (-Wno-psabi) |
| 33 | |
| 34 | if (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) |
| 56 | endif () |
| 57 | |
| 58 | if (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 | |
| 68 | endif () |
| 69 | |
| 70 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 71 | |
| 72 | # |
| 73 | # import OpenSSL (crypto) |
| 74 | find_package (OpenSSL REQUIRED) |
| 75 | include_directories (SYSTEM ${OPENSSL_INCLUDE_DIR}) |
| 76 | |
| 77 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}) |
| 78 | |
| 79 | add_library (zampoemcmds |
| 80 | SHARED |
Dung Cao | e71dce5 | 2021-06-11 10:23:42 +0000 | [diff] [blame] | 81 | src/bridgingcommands.cpp |
Hieu Huynh | 1463f70 | 2021-09-23 03:14:59 +0000 | [diff] [blame] | 82 | src/appcommands.cpp |
| 83 | src/oemcommands.cpp) |
Dung Cao | 956cbfc | 2021-06-11 09:24:57 +0000 | [diff] [blame] | 84 | |
| 85 | set_target_properties (zampoemcmds PROPERTIES VERSION "0.1.0") |
| 86 | set_target_properties (zampoemcmds PROPERTIES SOVERSION "0") |
| 87 | target_link_libraries (zampoemcmds stdc++fs) |
| 88 | target_link_libraries (zampoemcmds ipmid) |
| 89 | target_link_libraries (zampoemcmds sdbusplus) |
| 90 | target_link_libraries (zampoemcmds phosphor_logging) |
| 91 | target_link_libraries (zampoemcmds -luserlayer) |
| 92 | target_link_libraries (zampoemcmds -lchannellayer) |
| 93 | target_link_libraries (zampoemcmds ${OPENSSL_CRYPTO_LIBRARY}) |
| 94 | target_link_libraries (zampoemcmds gpiodcxx) |
| 95 | |
| 96 | install (TARGETS zampoemcmds DESTINATION lib/ipmid-providers) |
| 97 | |
| 98 | target_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 | ) |