diff --git a/source/application/api/fwk/tflm/CMakeLists.txt b/source/application/api/fwk/tflm/CMakeLists.txt index 6db9b1fb175af70bed53b3a9329c606e74d9568e..fc092bbae8ac5371c9b565414e759f2fe06d2120 100644 --- a/source/application/api/fwk/tflm/CMakeLists.txt +++ b/source/application/api/fwk/tflm/CMakeLists.txt @@ -35,7 +35,10 @@ endif() # including this project can provide its own version # of the target. if (NOT TARGET google::tensorflow-lite-micro) + set(TFLM_EXTERNAL_TARGET OFF) include(tensorflow_lite_micro) +else() + set(TFLM_EXTERNAL_TARGET ON) endif() # Create static library @@ -66,6 +69,15 @@ target_link_libraries(${ML_FWK_TFLM_TARGET} PUBLIC target_compile_definitions(${ML_FWK_TFLM_TARGET} INTERFACE MLEK_FWK_TFLM=1) +# Set the source file property to indicate that it should not use the logging +# facility from the Cortex-M CPU generic target unless it is an internally +# configured target. Reason: for external target, we can't assume that it +# compiles the sources required. +if (TFLM_EXTERNAL_TARGET) + set_source_files_properties(source/TensorFlowLiteMicro.cc + PROPERTIES COMPILE_DEFINITIONS TFLM_EXTERNAL_TARGET) +endif() + # Display status: message(STATUS "*******************************************************") message(STATUS "Library: " ${ML_FWK_TFLM_TARGET}) diff --git a/source/application/api/fwk/tflm/source/TensorFlowLiteMicro.cc b/source/application/api/fwk/tflm/source/TensorFlowLiteMicro.cc index 1ef0a2fc9c8d8e0dad0879e8450fdf2a6e4fbcf9..78515dea61e37db0cf65b0c901919e9c34fe1884 100644 --- a/source/application/api/fwk/tflm/source/TensorFlowLiteMicro.cc +++ b/source/application/api/fwk/tflm/source/TensorFlowLiteMicro.cc @@ -20,7 +20,7 @@ /* If target is arm-none-eabi and arch profile is 'M', wire the logging for * TensorFlow Lite Micro */ -#if defined(__arm__) && (__ARM_ARCH_PROFILE == 77) +#if defined(__arm__) && (__ARM_ARCH_PROFILE == 77) && !defined(TFLM_EXTERNAL_TARGET) #include "tensorflow/lite/micro/cortex_m_generic/debug_log_callback.h" #ifdef __cplusplus @@ -39,8 +39,8 @@ void arm::app::fwk::tflm::EnableTFLMLog() RegisterDebugLogCallback(TFLMLog); } -#else /* defined(__arm__) && (__ARM_ARCH_PROFILE == 77) */ +#else /* defined(__arm__) && (__ARM_ARCH_PROFILE == 77) && !defined(TFLM_EXTERNAL_TARGET) */ void arm::app::fwk::tflm::EnableTFLMLog() {} -#endif /* defined(__arm__) && (__ARM_ARCH_PROFILE == 77) */ +#endif /* defined(__arm__) && (__ARM_ARCH_PROFILE == 77) && !defined(TFLM_EXTERNAL_TARGET) */