@@ -24,33 +24,44 @@ SET(MLONMCU_BACKEND ${CONFIG_MLONMCU_BACKEND})
2424
2525SET (MLIF_SRCS ml_interface.c)
2626SET (CODEGEN_INCS ${MLONMCU_CODEGEN_DIR} )
27+ SET (CODEGEN_SRCS "" )
28+
2729IF ("${MLONMCU_FRAMEWORK} " STREQUAL "tflm" )
2830 SET (LIB_NAME tflite-lib)
2931 LIST (APPEND MLIF_SRCS ml_interface_tflm.cc)
30- FILE (GLOB CODEGEN_SRCS
31- ${MLONMCU_CODEGEN_DIR} /*.cc
32- ${MLONMCU_CODEGEN_DIR} /*.c
33- )
32+ # Only add codegen sources if CODEGEN_DIR is specified
33+ IF (NOT "${MLONMCU_CODEGEN_DIR} " STREQUAL "" )
34+ FILE (GLOB CODEGEN_SRCS
35+ ${MLONMCU_CODEGEN_DIR} /*.cc
36+ ${MLONMCU_CODEGEN_DIR} /*.c
37+ )
38+ ENDIF ()
3439
3540ELSEIF ("${MLONMCU_FRAMEWORK} " STREQUAL "tvm" )
3641 SET (LIB_NAME tvm-lib)
3742 LIST (APPEND MLIF_SRCS ml_interface_tvm.c)
38- FILE (GLOB CODEGEN_SRCS
39- ${MLONMCU_CODEGEN_DIR} /codegen/host/src/*.c
40- ${MLONMCU_CODEGEN_DIR} /codegen/host/src/*.cc
41- )
42- IF (EXISTS ${MLONMCU_CODEGEN_DIR} /codegen/host/include/)
43- LIST (APPEND CODEGEN_INCS ${MLONMCU_CODEGEN_DIR} /codegen/host/include /)
44- ENDIF ()
43+ # Model component provides the codegen files, so we don't need to add them here
44+ # Only add if CODEGEN_DIR is explicitly specified (backward compatibility)
45+ IF (NOT "${MLONMCU_CODEGEN_DIR} " STREQUAL "" )
46+ FILE (GLOB CODEGEN_SRCS_TMP
47+ ${MLONMCU_CODEGEN_DIR} /codegen/host/src/*.c
48+ ${MLONMCU_CODEGEN_DIR} /codegen/host/src/*.cc
49+ )
50+ LIST (APPEND CODEGEN_SRCS ${CODEGEN_SRCS_TMP} )
51+
52+ IF (EXISTS ${MLONMCU_CODEGEN_DIR} /codegen/host/include/)
53+ LIST (APPEND CODEGEN_INCS ${MLONMCU_CODEGEN_DIR} /codegen/host/include /)
54+ ENDIF ()
4555
46- IF ("${MLONMCU_BACKEND} " STREQUAL "tvmaot" )
47- LIST (APPEND CODEGEN_SRCS ${MLONMCU_CODEGEN_DIR} /aot_wrapper.c)
48- ELSEIF ("${MLONMCU_BACKEND} " STREQUAL "tvmrt" )
49- LIST (APPEND CODEGEN_SRCS ${MLONMCU_CODEGEN_DIR} /rt_wrapper.c)
50- ELSEIF ("${MLONMCU_BACKEND} " STREQUAL "tvmcg" )
51- LIST (APPEND CODEGEN_SRCS ${MLONMCU_CODEGEN_DIR} /staticrt.c)
52- ELSE ()
53- MESSAGE (WARNING "Invalid Backend: ${MLONMCU_BACKEND} " )
56+ IF ("${MLONMCU_BACKEND} " STREQUAL "tvmaot" )
57+ LIST (APPEND CODEGEN_SRCS ${MLONMCU_CODEGEN_DIR} /aot_wrapper.c)
58+ ELSEIF ("${MLONMCU_BACKEND} " STREQUAL "tvmrt" )
59+ LIST (APPEND CODEGEN_SRCS ${MLONMCU_CODEGEN_DIR} /rt_wrapper.c)
60+ ELSEIF ("${MLONMCU_BACKEND} " STREQUAL "tvmcg" )
61+ LIST (APPEND CODEGEN_SRCS ${MLONMCU_CODEGEN_DIR} /staticrt.c)
62+ ELSE ()
63+ MESSAGE (WARNING "Invalid Backend: ${MLONMCU_BACKEND} " )
64+ ENDIF ()
5465 ENDIF ()
5566ELSE ()
5667 MESSAGE (WARNING "Invalid Framework: ${MLONMCU_FRAMEWORK} " )
@@ -73,8 +84,8 @@ ENDIF()
7384
7485idf_component_register (SRCS ${CODEGEN_SRCS} ${MLIF_SRCS}
7586 INCLUDE_DIRS ${CODEGEN_INCS} ${CMAKE_CURRENT_SOURCE_DIR } /include
76- REQUIRES ${LIB_NAME} )
87+ REQUIRES ${LIB_NAME} model )
7788
7889component_compile_options (-Wno-error=missing-braces -Wno-incompatible-pointer-types -Wno-error=unused-const-variable )
7990
80- # target_compile_definitions(${COMPONENT_LIB} PUBLIC NUM_RUNS=${NUM_RUNS})
91+ # target_compile_definitions(${COMPONENT_LIB} PUBLIC NUM_RUNS=${NUM_RUNS})
0 commit comments