Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / compiler / mio-tflite2121 / CMakeLists.txt
1 nnas_find_package(FlatBuffers EXACT 2.0 QUIET)
2
3 if(NOT FlatBuffers_FOUND)
4   message(STATUS "Build mio-tflite2121: FAILED (missing Flatbuffers 2.0)")
5   return()
6 endif(NOT FlatBuffers_FOUND)
7
8 nnas_find_package(TensorFlowSource EXACT 2.12.1 QUIET)
9
10 if(NOT TensorFlowSource_FOUND)
11   message(STATUS "Build mio-tflite2121: FAILED (missing TensorFlowSource 2.12.1)")
12   return()
13 endif(NOT TensorFlowSource_FOUND)
14
15 message(STATUS "Build mio-tflite2121: TRUE")
16 message(STATUS "Build mio-tflite2121: with ${TensorFlowSource_DIR}")
17
18 set(SCHEMA_FILE "${TensorFlowSource_DIR}/tensorflow/lite/schema/schema.fbs")
19
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}"
25 )
26
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"
32 )
33
34 add_executable(mio_tflite2121_example example.cpp)
35 target_link_libraries(mio_tflite2121_example mio_tflite2121)
36
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)
41
42 file(GLOB_RECURSE SOURCES "src/*.cpp")
43 file(GLOB_RECURSE TESTS "src/*.test.cpp")
44 list(REMOVE_ITEM SOURCES ${TESTS})
45
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)
50
51 if(NOT ENABLE_TEST)
52   return()
53 endif(NOT ENABLE_TEST)
54
55 nnas_find_package(GTest REQUIRED)
56
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)