1 nnas_find_package(FlatBuffers EXACT 2.0 QUIET)
3 if(NOT FlatBuffers_FOUND)
4 message(STATUS "Build mio-tflite2121: FAILED (missing Flatbuffers 2.0)")
6 endif(NOT FlatBuffers_FOUND)
8 nnas_find_package(TensorFlowSource EXACT 2.12.1 QUIET)
10 if(NOT TensorFlowSource_FOUND)
11 message(STATUS "Build mio-tflite2121: FAILED (missing TensorFlowSource 2.12.1)")
13 endif(NOT TensorFlowSource_FOUND)
15 message(STATUS "Build mio-tflite2121: TRUE")
16 message(STATUS "Build mio-tflite2121: with ${TensorFlowSource_DIR}")
18 set(SCHEMA_FILE "${TensorFlowSource_DIR}/tensorflow/lite/schema/schema.fbs")
20 # NOTE Use copy of schema.fbs as to provide unified way for circle also
21 add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/schema.fbs"
22 COMMAND ${CMAKE_COMMAND} -E copy "${SCHEMA_FILE}" schema.fbs
23 WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
24 DEPENDS "${SCHEMA_FILE}"
27 FlatBuffers_Target(mio_tflite2121
28 OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/gen/mio/tflite"
29 INCLUDE_DIR "${CMAKE_CURRENT_BINARY_DIR}/gen"
30 SCHEMA_DIR "${CMAKE_CURRENT_BINARY_DIR}"
31 SCHEMA_FILES "schema.fbs"
34 add_executable(mio_tflite2121_example example.cpp)
35 target_link_libraries(mio_tflite2121_example mio_tflite2121)
37 # Temporay tflite validation tool to replace nnkit-tflite
38 # TODO provide full tflite validation with runtime/interpreter
39 add_executable(mio_tflite2121_validate example.cpp)
40 target_link_libraries(mio_tflite2121_validate mio_tflite2121)
42 file(GLOB_RECURSE SOURCES "src/*.cpp")
43 file(GLOB_RECURSE TESTS "src/*.test.cpp")
44 list(REMOVE_ITEM SOURCES ${TESTS})
46 add_library(mio_tflite2121_helper STATIC ${SOURCES})
47 target_include_directories(mio_tflite2121_helper PRIVATE src)
48 target_include_directories(mio_tflite2121_helper PUBLIC include)
49 target_link_libraries(mio_tflite2121_helper mio_tflite2121)
53 endif(NOT ENABLE_TEST)
55 nnas_find_package(GTest REQUIRED)
57 GTest_AddTest(mio_tflite2121_helper_test ${TESTS})
58 target_include_directories(mio_tflite2121_helper_test PRIVATE src)
59 target_link_libraries(mio_tflite2121_helper_test mio_tflite2121)
60 target_link_libraries(mio_tflite2121_helper_test mio_tflite2121_helper)