CMakeLists.txt 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ## TODO: GLOB is not a good way to collect files. Use explicit file list instead
  2. cmake_minimum_required(VERSION 3.5)
  3. set(tflite_dir "${CMAKE_CURRENT_SOURCE_DIR}/tensorflow/lite")
  4. set(tfmicro_dir "${tflite_dir}/micro")
  5. set(tfmicro_frontend_dir "${tflite_dir}/experimental/microfrontend/lib")
  6. set(tfmicro_kernels_dir "${tfmicro_dir}/kernels")
  7. file(GLOB srcs_micro
  8. "${tfmicro_dir}/*.cc"
  9. "${tfmicro_dir}/*.c")
  10. file(GLOB src_micro_frontend
  11. "${tfmicro_frontend_dir}/*.c"
  12. "${tfmicro_frontend_dir}/*.cc")
  13. file(GLOB srcs_kernels
  14. "${tfmicro_kernels_dir}/*.c"
  15. "${tfmicro_kernels_dir}/*.cc")
  16. # remove sources which will be provided by esp_nn
  17. list(REMOVE_ITEM srcs_kernels
  18. "${tfmicro_kernels_dir}/add.cc"
  19. "${tfmicro_kernels_dir}/conv.cc"
  20. "${tfmicro_kernels_dir}/depthwise_conv.cc"
  21. "${tfmicro_kernels_dir}/fully_connected.cc"
  22. "${tfmicro_kernels_dir}/mul.cc"
  23. "${tfmicro_kernels_dir}/pooling.cc"
  24. "${tfmicro_kernels_dir}/softmax.cc")
  25. FILE(GLOB esp_nn_kernels
  26. "${tfmicro_kernels_dir}/esp_nn/*.cc")
  27. set(lib_srcs
  28. "${srcs_micro}"
  29. "${srcs_kernels}"
  30. "${esp_nn_kernels}"
  31. "${src_micro_frontend}"
  32. "${tflite_dir}/kernels/kernel_util.cc"
  33. "${tflite_dir}/micro/memory_planner/greedy_memory_planner.cc"
  34. "${tflite_dir}/micro/memory_planner/linear_memory_planner.cc"
  35. "${tflite_dir}/micro/arena_allocator/non_persistent_arena_buffer_allocator.cc"
  36. "${tflite_dir}/micro/arena_allocator/persistent_arena_buffer_allocator.cc"
  37. "${tflite_dir}/micro/arena_allocator/recording_single_arena_buffer_allocator.cc"
  38. "${tflite_dir}/micro/arena_allocator/single_arena_buffer_allocator.cc"
  39. "${tflite_dir}/c/common.cc"
  40. "${tflite_dir}/core/api/error_reporter.cc"
  41. "${tflite_dir}/core/api/flatbuffer_conversions.cc"
  42. "${tflite_dir}/core/api/op_resolver.cc"
  43. "${tflite_dir}/core/api/tensor_utils.cc"
  44. "${tflite_dir}/kernels/internal/quantization_util.cc"
  45. "${tflite_dir}/schema/schema_utils.cc")
  46. idf_component_register(
  47. SRCS "${lib_srcs}"
  48. INCLUDE_DIRS "." "third_party/gemmlowp"
  49. "third_party/flatbuffers/include"
  50. "third_party/ruy"
  51. "third_party/kissfft"
  52. REQUIRES "esp-nn")
  53. # Reduce the level of paranoia to be able to compile TF sources
  54. target_compile_options(${COMPONENT_LIB} PRIVATE
  55. -Wno-maybe-uninitialized
  56. -Wno-missing-field-initializers
  57. -DESP_NN # enables ESP-NN optimizations by Espressif
  58. -Wno-type-limits)
  59. target_compile_options(${COMPONENT_LIB} PRIVATE -fno-unwind-tables -ffunction-sections -fdata-sections -fmessage-length=0 -DTF_LITE_STATIC_MEMORY -DTF_LITE_DISABLE_X86_NEON -O3 -Wsign-compare -Wdouble-promotion -Wshadow -Wunused-variable -Wmissing-field-initializers -Wunused-function -Wswitch -Wvla -Wall -Wextra -Wstrict-aliasing -Wno-unused-parameter -Wno-nonnull)
  60. target_compile_options(${COMPONENT_LIB} PRIVATE $<$<COMPILE_LANGUAGE:CXX>: -std=c++11 -fno-rtti -fno-exceptions -fno-threadsafe-statics -fno-unwind-tables -ffunction-sections -fdata-sections -fmessage-length=0 -DTF_LITE_STATIC_MEMORY -DTF_LITE_DISABLE_X86_NEON -O3 -Werror -Wsign-compare -Wdouble-promotion -Wshadow -Wunused-variable -Wmissing-field-initializers -Wunused-function -Wswitch -Wvla -Wall -Wextra -Wstrict-aliasing -Wno-unused-parameter -Wno-return-type -Wno-strict-aliasing -std=gnu++14 >)
  61. target_compile_options(${COMPONENT_LIB} INTERFACE $<$<IN_LIST:-DTF_LITE_STATIC_MEMORY,$<TARGET_PROPERTY:${COMPONENT_LIB},COMPILE_OPTIONS>>:-DTF_LITE_STATIC_MEMORY>)
  62. target_link_libraries(${COMPONENT_LIB} PRIVATE -lm)