在tensorflow /lite目錄下創建CMakeLists.txt文件,內容如下:
cmake_minimum_required(VERSION 3.5)
project(tflite)
set(LITE_DIR CMAKE_CURRENT_SOURCE_DIR)
add_compile_options(-std=c++11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Lstdc++ -Lpthread -Lm -Lz")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O -fPIC")
#include dir of lite
aux_source_directory(. DIR_SRCS)
#include files
include_directories(
./
./../
./../../
./../../../
tools/make/downloads/
tools/make/downloads/eigen
tools/make/downloads/absl
tools/make/downloads/gemmlowp
tools/make/downloads/neon_2_sse
tools/make/downloads/farmhash/src
tools/make/downloads/flatbuffers/include
/usr/local/include
)
#===========================source files
# Benchmark static library and binary
set(BENCHMARK_LIB_NAME benchmark-lib)
set(BENCHMARK_BINARY_NAME benchmark_model)
# A small example program that shows how to link against the library.
set(MINIMAL_SRCS ${LITE_DIR}/examples/minimal/minimal.cc)
set(PROFILER_SRCS ${LITE_DIR}/profiling/time.cc)
set(PROFILE_SUMMARIZER_SRCS ${LITE_DIR}/profiling/profile_summarizer.cc tensorflow/core/util/stats_calculator.cc)
set(CMD_LINE_TOOLS_SRCS ${LITE_DIR}/tools/command_line_flags.cc)
#find sources
file(GLOB_RECURSE CORE_CC_ALL_SRCS
${LITE_DIR}
"*.cc" "*.c" "*.cpp")
set(SRC_LIST CORE_CC_ALL_SRCS)
set(SRC_LIST ${SRC_LIST} DIR_SRCS MINIMAL_SRCS PROFILER_SRCS PROFILE_SUMMARIZER_SRCS CMD_LINE_TOOLS_SRCS)
#target_link_libraries(label_image stdc++ libstdc++ libphtread libm libz)
add_executable(label_image ./examples/label_image/label_image.cc)
#add_library(tflite_r2 ${SRC_LIST})