From fa152665577a124cd957756f78fb81419c095c87 Mon Sep 17 00:00:00 2001 From: Tom Burdick Date: Wed, 10 Jul 2024 16:02:29 -0500 Subject: [PATCH 1/2] Support libmctp as a zephyr module Signed-off-by: Tom Burdick --- zephyr/CMakeLists.txt | 22 ++++++++++++++++++++++ zephyr/module.yml | 3 +++ 2 files changed, 25 insertions(+) create mode 100644 zephyr/CMakeLists.txt create mode 100644 zephyr/module.yml diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt new file mode 100644 index 00000000..a4492b3f --- /dev/null +++ b/zephyr/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright (c) 2024 Intel Corporation. +# +# SPDX-License-Identifier: BSD-3-Clause + +set(MCTP_SRC ${CMAKE_CURRENT_SOURCE_DIR}/..) + +zephyr_interface_library_named(mctp) +target_link_libraries(zephyr_interface INTERFACE mctp) +target_include_directories(mctp INTERFACE ${MCTP_SRC}) + +zephyr_library_named(modules_mctp) +zephyr_library_link_libraries(mctp) + +zephyr_library_sources_ifdef( + CONFIG_MCTP + ${MCTP_SRC}/alloc.c + ${MCTP_SRC}/crc32.c + ${MCTP_SRC}/core.c + ${MCTP_SRC}/log.c + ${MCTP_SRC}/libmctp.h + ${MCTP_SRC}/crc-16-ccitt.c +) diff --git a/zephyr/module.yml b/zephyr/module.yml new file mode 100644 index 00000000..35f791c5 --- /dev/null +++ b/zephyr/module.yml @@ -0,0 +1,3 @@ +name: libmctp +build: + cmake: zephyr From c76697e4bf9927d3a71eef587bbb8ec224570394 Mon Sep 17 00:00:00 2001 From: Tom Burdick Date: Wed, 15 Jan 2025 08:49:56 -0600 Subject: [PATCH 2/2] Fix module compilation warning When CONFIG_MCTP was not set the library sources would be empty and result in a CMake warning. Wrap entire CMake file in an if(CONFIG_MCTP) to ensure nothing is done when CONFIG_MCTP is not set. Signed-off-by: Tom Burdick --- zephyr/CMakeLists.txt | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index a4492b3f..b51e7077 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -2,21 +2,23 @@ # # SPDX-License-Identifier: BSD-3-Clause -set(MCTP_SRC ${CMAKE_CURRENT_SOURCE_DIR}/..) +if(CONFIG_MCTP) + set(MCTP_SRC ${CMAKE_CURRENT_SOURCE_DIR}/..) -zephyr_interface_library_named(mctp) -target_link_libraries(zephyr_interface INTERFACE mctp) -target_include_directories(mctp INTERFACE ${MCTP_SRC}) + zephyr_interface_library_named(mctp) + target_link_libraries(zephyr_interface INTERFACE mctp) + target_include_directories(mctp INTERFACE ${MCTP_SRC}) -zephyr_library_named(modules_mctp) -zephyr_library_link_libraries(mctp) + zephyr_library_named(modules_mctp) + zephyr_library_link_libraries(mctp) -zephyr_library_sources_ifdef( - CONFIG_MCTP - ${MCTP_SRC}/alloc.c - ${MCTP_SRC}/crc32.c - ${MCTP_SRC}/core.c - ${MCTP_SRC}/log.c - ${MCTP_SRC}/libmctp.h - ${MCTP_SRC}/crc-16-ccitt.c -) + zephyr_library_sources_ifdef( + CONFIG_MCTP + ${MCTP_SRC}/alloc.c + ${MCTP_SRC}/crc32.c + ${MCTP_SRC}/core.c + ${MCTP_SRC}/log.c + ${MCTP_SRC}/libmctp.h + ${MCTP_SRC}/crc-16-ccitt.c + ) +endif()