Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 1 | cmake_minimum_required (VERSION 3.5 FATAL_ERROR) |
| 2 | |
| 3 | cmake_policy (SET CMP0054 NEW) |
| 4 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 5 | option (YOCTO "Use YOCTO depedencies system" OFF) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 6 | include (ExternalProject) |
Patrick Williams | ac0b727 | 2022-09-01 15:09:18 -0500 | [diff] [blame] | 7 | set (CMAKE_CXX_STANDARD 20) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 8 | set (CMAKE_CXX_STANDARD_REQUIRED ON) |
| 9 | set (CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) |
| 10 | |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 11 | option (USING_ENTITY_MANAGER_DECORATORS |
| 12 | "Enable using EM decorators to map FRUs to entity IDs" ON) |
| 13 | |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 14 | set ( |
| 15 | CMAKE_CXX_FLAGS |
| 16 | "${CMAKE_CXX_FLAGS} \ |
| 17 | -Werror \ |
| 18 | -Wtype-limits \ |
| 19 | -Wnull-dereference \ |
| 20 | " |
| 21 | ) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 22 | |
| 23 | project (intel-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) |
Vernon Mauery | 9e7e17a | 2019-03-20 13:42:06 -0700 | [diff] [blame] | 30 | add_definitions (-DBOOST_ASIO_DISABLE_THREADS) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 31 | add_definitions (-DBOOST_COROUTINES_NO_DEPRECATION_WARNING) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 32 | add_definitions (-Wno-psabi) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 33 | |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 34 | if (NOT YOCTO) # headers that can't be built without yocto |
Vernon Mauery | 6207207 | 2022-06-15 11:42:33 -0700 | [diff] [blame] | 35 | |
| 36 | execute_process( |
| 37 | COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine |
| 38 | OUTPUT_VARIABLE TRIPLE OUTPUT_STRIP_TRAILING_WHITESPACE) |
| 39 | message(STATUS "Target triple: ${TRIPLE}") |
| 40 | |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 41 | include_directories (SYSTEM non-yocto) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 42 | |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 43 | configure_file (CMakeLists.txt.in 3rdparty/CMakeLists.txt) |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 44 | execute_process (COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . |
| 45 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty) |
| 46 | execute_process (COMMAND ${CMAKE_COMMAND} --build . |
| 47 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/3rdparty) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 48 | |
| 49 | set (CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/prefix ${CMAKE_PREFIX_PATH}) |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 50 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}/prefix/include) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 51 | link_directories (${CMAKE_BINARY_DIR}/prefix/lib) |
Vernon Mauery | 6207207 | 2022-06-15 11:42:33 -0700 | [diff] [blame] | 52 | link_directories (${CMAKE_BINARY_DIR}/prefix/lib/${TRIPLE}) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 53 | |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 54 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}/sdbusplus-src) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 55 | link_directories (${CMAKE_BINARY_DIR}/sdbusplus-src/.libs) |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 56 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}/phosphor-logging-src) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 57 | link_directories (${CMAKE_BINARY_DIR}/phosphor-logging-src/.libs) |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 58 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}/phosphor-ipmi-host/include) |
| 59 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}/ipmid/user_channel) |
| 60 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}) # link_directories (${CMAK |
| 61 | # E_BINARY_DIR}/sdbusplus- |
| 62 | # src/.libs) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 63 | endif () |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 64 | |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 65 | if (YOCTO) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 66 | find_package (PkgConfig REQUIRED) |
| 67 | pkg_check_modules (LOGGING phosphor-logging REQUIRED) |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 68 | include_directories (SYSTEM ${LOGGING_INCLUDE_DIRS}) |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 69 | link_directories (${LOGGING_LIBRARY_DIRS}) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 70 | |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 71 | pkg_check_modules (LIBIPMID libipmid REQUIRED) |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 72 | include_directories (SYSTEM ${LIBIPMID_INCLUDE_DIRS}) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 73 | link_directories (${LIBIPMID_LIBRARY_DIRS}) |
| 74 | |
Ivan Mikhaylov | ac330b8 | 2023-05-25 13:48:59 +0000 | [diff] [blame] | 75 | |
| 76 | pkg_check_modules (TINYXML2 tinyxml2 REQUIRED) |
| 77 | include_directories (SYSTEM ${TINYXML2_INCLUDE_DIRS}) |
| 78 | link_directories (${TINYXML2_LIBRARY_DIRS}) |
| 79 | |
Jia, Chunhui | a835eaa | 2018-09-05 09:00:41 +0800 | [diff] [blame] | 80 | endif () |
| 81 | |
| 82 | include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include) |
| 83 | |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 84 | if (NOT YOCTO) |
Jason M. Bills | 72867de | 2018-11-28 12:46:59 -0800 | [diff] [blame] | 85 | set (SENSOR_TEST_SRC tests/test_sensorcommands.cpp) |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 86 | |
| 87 | find_package (GTest REQUIRED) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 88 | |
| 89 | enable_testing () |
| 90 | |
| 91 | add_executable (runSensorTests ${SENSOR_TEST_SRC}) |
| 92 | add_test (NAME test_sensorcommands COMMAND runSensorTests) |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 93 | target_link_libraries (runSensorTests ${GTEST_BOTH_LIBRARIES} |
| 94 | ${CMAKE_THREAD_LIBS_INIT} sdbusplus -lsystemd) |
Jason M. Bills | 3f7c5e4 | 2018-10-03 14:00:41 -0700 | [diff] [blame] | 95 | endif () |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 96 | # |
| 97 | # import OpenSSL (crypto) |
| 98 | find_package (OpenSSL REQUIRED) |
James Feist | 13b0039 | 2019-08-19 16:16:08 -0700 | [diff] [blame] | 99 | include_directories (SYSTEM ${OPENSSL_INCLUDE_DIR}) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 100 | |
Vernon Mauery | 0d0cd16 | 2020-01-31 10:04:10 -0800 | [diff] [blame] | 101 | include_directories (SYSTEM ${CMAKE_BINARY_DIR}) |
Vernon Mauery | 8b7c156 | 2022-09-27 16:10:38 -0700 | [diff] [blame] | 102 | add_custom_command(OUTPUT include/ipmi-allowlist.hpp |
| 103 | COMMAND ./generate-allowlist.py |
| 104 | ARGS ipmi-allowlist.conf ${CMAKE_BINARY_DIR}/ipmi-allowlist.hpp |
| 105 | MAIN_DEPENDENCY ipmi-allowlist.conf |
| 106 | DEPENDS generate-allowlist.py |
Vernon Mauery | 0d0cd16 | 2020-01-31 10:04:10 -0800 | [diff] [blame] | 107 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) |
| 108 | |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 109 | add_library (zinteloemcmds |
Kuiying Wang | 6d6dc7a | 2020-04-02 10:15:19 +0800 | [diff] [blame] | 110 | SHARED src/oemcommands.cpp src/sensorcommands.cpp src/biosconfigcommands.cpp |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 111 | src/storagecommands.cpp src/multinodecommands.cpp |
Vernon Mauery | c8b0c46 | 2022-09-27 16:01:25 -0700 | [diff] [blame] | 112 | src/firmware-update.cpp src/appcommands.cpp |
Jason M. Bills | b08f84e | 2019-06-10 12:59:42 -0700 | [diff] [blame] | 113 | src/smbiosmdrv2handler.cpp src/manufacturingcommands.cpp |
| 114 | src/bmccontrolservices.cpp src/bridgingcommands.cpp |
Agnieszka Szlendak | d2220cc | 2020-04-17 15:00:12 +0200 | [diff] [blame] | 115 | src/ipmi_to_redfish_hooks.cpp src/me_to_redfish_hooks.cpp |
Vernon Mauery | 8b7c156 | 2022-09-27 16:10:38 -0700 | [diff] [blame] | 116 | src/chassiscommands.cpp src/allowlist-filter.cpp |
| 117 | include/ipmi-allowlist.hpp) |
Richard Marian Thomaiyar | 6e05641 | 2018-11-14 23:26:49 +0530 | [diff] [blame] | 118 | set_target_properties (zinteloemcmds PROPERTIES VERSION "0.1.0") |
| 119 | set_target_properties (zinteloemcmds PROPERTIES SOVERSION "0") |
Vernon Mauery | 4ac799d | 2019-05-20 15:50:37 -0700 | [diff] [blame] | 120 | target_link_libraries (zinteloemcmds stdc++fs) |
Vernon Mauery | 8b69fae | 2019-03-20 13:43:11 -0700 | [diff] [blame] | 121 | target_link_libraries (zinteloemcmds ipmid) |
Richard Marian Thomaiyar | 6e05641 | 2018-11-14 23:26:49 +0530 | [diff] [blame] | 122 | target_link_libraries (zinteloemcmds sdbusplus) |
James Feist | a128f49 | 2018-12-20 12:31:56 -0800 | [diff] [blame] | 123 | target_link_libraries (zinteloemcmds phosphor_logging) |
Suryakanth Sekar | d509eb9 | 2018-11-15 17:44:11 +0530 | [diff] [blame] | 124 | target_link_libraries (zinteloemcmds -luserlayer) |
| 125 | target_link_libraries (zinteloemcmds -lchannellayer) |
Vernon Mauery | a3702c1 | 2019-05-22 13:20:59 -0700 | [diff] [blame] | 126 | target_link_libraries (zinteloemcmds ${OPENSSL_CRYPTO_LIBRARY}) |
Yong Li | d3f2ec3 | 2019-12-25 17:51:48 +0800 | [diff] [blame] | 127 | target_link_libraries (zinteloemcmds gpiodcxx) |
Kuiying Wang | 6d6dc7a | 2020-04-02 10:15:19 +0800 | [diff] [blame] | 128 | target_link_libraries (zinteloemcmds tinyxml2) |
| 129 | |
James Feist | b968392 | 2019-01-02 15:04:45 -0800 | [diff] [blame] | 130 | install (TARGETS zinteloemcmds DESTINATION lib/ipmid-providers) |
Rajashekar Gade Reddy | df5e327 | 2019-09-05 18:10:53 +0530 | [diff] [blame] | 131 | option (INTEL_PFR_ENABLED "Intel PFR Enabled" OFF) |
Richard Marian Thomaiyar | 99d7d35 | 2019-11-11 12:11:35 +0530 | [diff] [blame] | 132 | option (BMC_VALIDATION_UNSECURE_FEATURE |
| 133 | "Enables unsecure features required by validation. Note: must |
| 134 | be turned off for production images." |
| 135 | OFF) |
Yong Li | 38b58f5 | 2019-12-24 09:29:25 +0800 | [diff] [blame] | 136 | |
Rajashekar Gade Reddy | df5e327 | 2019-09-05 18:10:53 +0530 | [diff] [blame] | 137 | target_compile_definitions ( |
| 138 | zinteloemcmds PRIVATE |
| 139 | $<$<BOOL:${INTEL_PFR_ENABLED}>: -DINTEL_PFR_ENABLED> |
Richard Marian Thomaiyar | 99d7d35 | 2019-11-11 12:11:35 +0530 | [diff] [blame] | 140 | $<$<BOOL:${BMC_VALIDATION_UNSECURE_FEATURE}>: |
| 141 | -DBMC_VALIDATION_UNSECURE_FEATURE> |
James Feist | 2569025 | 2019-12-23 12:25:49 -0800 | [diff] [blame] | 142 | $<$<BOOL:${USING_ENTITY_MANAGER_DECORATORS}>: |
| 143 | -DUSING_ENTITY_MANAGER_DECORATORS> |
Rajashekar Gade Reddy | df5e327 | 2019-09-05 18:10:53 +0530 | [diff] [blame] | 144 | ) |
Rui Zhang | aedf5a9 | 2020-09-03 09:57:33 -0700 | [diff] [blame] | 145 | |
| 146 | # Code Coverage |
Vernon Mauery | dcff150 | 2022-09-28 11:12:46 -0700 | [diff] [blame] | 147 | if (FALSE) |
Rui Zhang | aedf5a9 | 2020-09-03 09:57:33 -0700 | [diff] [blame] | 148 | # non-Debug build may generate misleading code coverage results. |
| 149 | set(CMAKE_BUILD_TYPE Debug) |
| 150 | message(WARNING "Using Debug build type!") |
| 151 | include(CodeCoverage) |
| 152 | APPEND_COVERAGE_COMPILER_FLAGS() |
| 153 | # check-code-coverage is a required name by |
| 154 | # openbmc-build-scripts/scripts/unit-test.py#L487. |
| 155 | SETUP_TARGET_FOR_COVERAGE_LCOV( |
| 156 | NAME check-code-coverage |
| 157 | EXECUTABLE runSensorTests |
| 158 | DEPENDENCIES runSensorTests |
| 159 | EXCLUDE "/usr/include/*" "/usr/local/include/*" "prefix/*" |
| 160 | ) |
| 161 | endif () |