From 00d88427d3e614b52c47e3c07c3145973fbf64d8 Mon Sep 17 00:00:00 2001 From: Jiacheng Guo Date: Fri, 21 Aug 2020 01:11:23 +0800 Subject: [PATCH] [cmake] allow set extension sources in cmake (#5419) --- script/check-simulation-build-cmake | 2 ++ src/core/CMakeLists.txt | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/script/check-simulation-build-cmake b/script/check-simulation-build-cmake index a31acfa77..84ab2b592 100755 --- a/script/check-simulation-build-cmake +++ b/script/check-simulation-build-cmake @@ -44,6 +44,8 @@ build_all_features() "$(dirname "$0")"/cmake-build simulation -DOT_OTNS=ON -DOT_SIMULATION_VIRTUAL_TIME=ON reset_source "$(dirname "$0")"/cmake-build simulation -DOT_OTNS=ON -DOT_SIMULATION_VIRTUAL_TIME=ON -DOT_ASSERT=OFF + reset_source + "$(dirname "$0")"/cmake-build simulation -DOT_VENDOR_EXTENSION=../../src/core/common/extension_example.cpp } build_toranj() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f5dc4dfe1..09b4f6ba9 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -217,6 +217,11 @@ target_include_directories(openthread-ftd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE $ target_include_directories(openthread-mtd PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) target_include_directories(openthread-radio PUBLIC ${OT_PUBLIC_INCLUDES} PRIVATE ${COMMON_INCLUDES}) +set(OT_VENDOR_EXTENSION "" CACHE STRING "specify a C++ source file built as part of OpenThread core library") +if(OT_VENDOR_EXTENSION) + target_compile_definitions(ot-config INTERFACE "OPENTHREAD_ENABLE_VENDOR_EXTENSION=1") + list(APPEND COMMON_SOURCES ${OT_VENDOR_EXTENSION}) +endif() target_sources(openthread-ftd PRIVATE ${COMMON_SOURCES}) target_sources(openthread-mtd PRIVATE ${COMMON_SOURCES}) @@ -248,6 +253,10 @@ target_sources(openthread-radio PRIVATE utils/parse_cmdline.cpp ) +if(OT_VENDOR_EXTENSION) + target_sources(openthread-radio PRIVATE ${OT_VENDOR_EXTENSION}) +endif() + target_link_libraries(openthread-ftd PRIVATE ${OT_MBEDTLS}