Imported Upstream version 1.7.0
[platform/core/ml/nnfw.git] / infra / nnfw / cmake / packages / TensorFlowLite-1.13.1 / TensorFlowLite / CMakeLists.txt
1 set(TENSORFLOW_LITE_BASE ${TensorFlowSource_DIR}/tensorflow/lite)
2
3 #
4 # Tensorflow Lite library
5 #
6 file(GLOB TFLITE_CORE_SRCS "${TENSORFLOW_LITE_BASE}/*.c" "${TENSORFLOW_LITE_BASE}/*.cc" "${TENSORFLOW_LITE_BASE}/core/*.cc")
7 file(GLOB TFLITE_CORE_TESTS "${TENSORFLOW_LITE_BASE}/*test*.cc")
8 list(REMOVE_ITEM TFLITE_CORE_SRCS ${TFLITE_CORE_TESTS})
9
10 file(GLOB_RECURSE TFLITE_KERNEL_SRCS "${TENSORFLOW_LITE_BASE}/kernels/*.cc")
11 file(GLOB_RECURSE TFLITE_KERNEL_TESTS "${TENSORFLOW_LITE_BASE}/kernels/*test*.cc")
12 list(REMOVE_ITEM TFLITE_KERNEL_SRCS ${TFLITE_KERNEL_TESTS})
13
14 file(GLOB TFLITE_LIB_SRCS "${TENSORFLOW_LITE_BASE}/c/*.c" "${TENSORFLOW_LITE_BASE}/c/*.cc")
15 file(GLOB TFLITE_LIB_TESTS "${TENSORFLOW_LITE_BASE}/c/*test*.cc")
16 list(REMOVE_ITEM TFLITE_LIB_SRCS ${TFLITE_LIB_TESTS})
17
18 file(GLOB TFLITE_API_SRCS "${TENSORFLOW_LITE_BASE}/core/api/*.c" "${TENSORFLOW_LITE_BASE}/core/api/*.cc")
19 file(GLOB TFLITE_API_TESTS "${TENSORFLOW_LITE_BASE}/core/api/*test*.cc")
20 list(REMOVE_ITEM TFLITE_API_SRCS ${TFLITE_API_TESTS})
21
22 file(GLOB TFLITE_PROFILING_SRCS "${TENSORFLOW_LITE_BASE}/profiling/*.cc")
23 file(GLOB TFLITE_PROFILING_TESTS "${TENSORFLOW_LITE_BASE}/profiling/*test*.cc")
24 list(REMOVE_ITEM TFLITE_PROFILING_SRCS ${TFLITE_PROFILING_TESTS})
25
26 # We will use our own BuiltinOpResolver
27 list(REMOVE_ITEM TFLITE_KERNEL_SRCS "${TENSORFLOW_LITE_BASE}/kernels/register.cc")
28 # We will use our own summarizer
29 list(REMOVE_ITEM TFLITE_PROFILING_SRCS "${TENSORFLOW_LITE_BASE}/profiling/profile_summarizer.cc")
30 list(APPEND TFLITE_SRCS ${TFLITE_CORE_SRCS})
31 list(APPEND TFLITE_SRCS ${TFLITE_KERNEL_SRCS})
32 list(APPEND TFLITE_SRCS ${TFLITE_LIB_SRCS})
33 list(APPEND TFLITE_SRCS ${TFLITE_API_SRCS})
34 list(APPEND TFLITE_SRCS ${TFLITE_PROFILING_SRCS})
35
36 list(APPEND TFLITE_SRCS "${FarmhashSource_DIR}/src/farmhash.cc")
37
38 list(APPEND TFLITE_INCLUDES "${TensorFlowSource_DIR}")
39 list(APPEND TFLITE_INCLUDES "${AbseilSource_DIR}")
40 list(APPEND TFLITE_INCLUDES "${GEMMLowpSource_DIR}")
41 list(APPEND TFLITE_INCLUDES "${FarmhashSource_DIR}/src")
42
43 if(NEON2SSESource_FOUND)
44   list(APPEND TFLITE_INCLUDES "${NEON2SSESource_DIR}")
45 endif(NEON2SSESource_FOUND)
46
47 # This kernels are not used on nnfw
48 ## spectrogram
49 list(REMOVE_ITEM TFLITE_SRCS "${TENSORFLOW_LITE_BASE}/kernels/audio_spectrogram.cc")
50 list(REMOVE_ITEM TFLITE_SRCS "${TENSORFLOW_LITE_BASE}/kernels/audio_spectrogram_test.cc")
51 list(REMOVE_ITEM TFLITE_SRCS "${TENSORFLOW_LITE_BASE}/kernels/internal/spectrogram.cc")
52
53 add_library(tensorflow-lite STATIC ${TFLITE_SRCS})
54 target_include_directories(tensorflow-lite SYSTEM PUBLIC ${TFLITE_INCLUDES})
55 target_compile_definitions(tensorflow-lite PUBLIC "GEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK")
56 set_property(TARGET tensorflow-lite PROPERTY POSITION_INDEPENDENT_CODE ON)
57 target_link_libraries(tensorflow-lite eigen-tf-1.13.1 flatbuffers::flatbuffers ${LIB_PTHREAD} dl)
58
59 if(ANDROID)
60   target_link_libraries(tensorflow-lite log)
61   target_include_directories(tensorflow-lite PUBLIC "${NDK_DIR}/..")
62 endif()